日期:2014-05-16  浏览次数:20426 次

Oracle中的DDL语句

Oracle中的DDL语句


一、表格(table)

1.创建


  • 创建语句创建
create table t_1(
id int primary key,
name varchar(20)
);
  • ?利用其他的表创建
create table t_2 as select * from dept;-----复制dept表
create table t_2 as select * from dept where 1=2;-----创建与dept相同表结构的表
2.删除
  • 丢弃表格(包括字段和记录)
drop table t_1;
  • 删除数据(包括记录,不删除字段)
delete from t_1;
truncate table t_1;
注意:
delete只是将表中的数据并不释放 这些数据所占的空间 truncate不仅删除表中的数据而且还释放 数据所在的空间

3.重命名

rename t_1 to t;


二、表格中的字段(column)

  1. 增: alter table t_1 add score int ;
  2. 删: ? ?alter table t_1 drop (score?);
  3. 改: ? ?alter table t_1 modify scale int
  4. 重命名:?alter table t_1 rename column scale to grade

三、约束(constraint)

1.增