// 创建表空间
create tablespace ts datafile ‘E:/ts.dbf’
size 10m
autoextend on next 1m
maxsize 100m;
// 创建用户,并制定表空间
create user yx identified by yx;
//-
create table t_hash_partation(
tid int,
tname varchar2(20)
)
partition by hash(tid)
(
partition p1 tablespace users,
partition p2 tablespace TS
);
//oracle分区
//创建全局临时表
create global temporary table t (id int);
// 修改id列的数据类型
alter table t modify id varchar2(10)
// 向id列 添加约束 check(id<10)
alter table t add constraint id_check check(id < 10);
alter table t modify id constraint id__check check(id > 1);
// 修改tid列的默认值为10
alter table t modify tid default 10;
// 创建一个表,引用外键
create table t(
tid int,
tname varchar2(10),
tno number(4) primary key references emp(EMPNO)
);
//禁用约束
alter table emp disable constraint insertinfo;
//延迟约束,在commit时检查
alter table t drop column tno;
alter table t
add constraint tno_fk tno references emp(empno)
// 删除约束
alter table t drop constraint tno_fk;
//修改某一列为主键
alter table t modify tno reference emp(empno);
//修改某一列为pk
alter table t modify tno primary key ;