Oracle表的管理

1 表和列的命名规则
 a. 必须以字母开头
 b. 长度不能超过30个字符
 c. 不能使用Oracle的保留字(关键字)
 d. 只能使用如下字符A-Z,a-z,0-9,$,#

2 创建表
 语法:create table 表名 (列名 数据类型,列名 数据类型,...)
 SQL> create table Student (StuNo number(10),Gender char(4),Birthday date,Address varchar(20));
 
3 添加列
 语法:alter table Student add (列名 数据类型)
 SQL> alter table Student add (ClassNo char(15));
 
4 修改列的长度
 语法:alter table Student modify (列名 数据类型)
 SQL> alter table Student modify (Address varchar(15));
 
5 修改列的类型
 语法: alter table Student modify (列名 数据类型)
 SQL> alter table Student modify (Address varchar(15));
 
6 删除列
 语法: alter table Student drop column 列名
 SQL> alter table Student drop column Address;
 
7 修改表名
 语法: rename 原表名 to 新表名
 SQL> rename Student to Student1;
 
8 删除表
 语法: drop table 表名
 SQL> drop table Student;
 
9 插入值
 语法:insert into Student values ("值1","值2","值3","值4","值5")
 SQL> insert into Student values ("09110120","男","27-5-1987","中国北京");
 
10 更改默认日期格式
 Oracle中默认的日期格式是“dd-MON-YY”
 语法:alter session set nls_date_format = '新日期格式'
 SQL> alter session set nls_date_format = 'yyyy-mm-dd'
 
11 修改记录
 语法:update 表名 set 列名='值1'
 SQL> update Student set Address = '中国上海' where StuNo = '09110120';
 
12 删除表中的信息
 语法:delete from 表名
 SQL> delete from Student
 
14 删除表中的某一条记录
 语法:delete from 表名 where 条件
 SQL> delete from Student where StuNo='09110120';
 
15  删除表中的信息(无法回滚)
 语法:truncate table 表名
 SQL> truncate table Student;
 特点:删除表中的信息,速度快。由于不写日志,所以无法回滚找回删除的数据
 
16 创建里程碑
 SQL>
savepoint 里程碑名称
 
 
 
 
 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值