laotan

--建一个表
create table HH2(

tid number primary key ,--主键设定

tname varchar2(20)

);

--删除表
drop table HH;

 

--表空间(相当于一个数据库)(DBA权限)
create tablespace test
datafile \'D:test.dbf\'
size 10M
autoextend on
next 10M
maxsize 100M

--指定表在那个表空间里面(默认在USERS表空间里)
create table HH(tid number primary key)
tablespace test;
select * from tabs;

--删除 表空间
drop tablespace test including contents and datafiles --连带物理文件和表空间中的数据也一起删除

 

 

--建表建约束
create table student1(
sid number primary key ,
sname varchar2(20) not null,
sage number,
ssex char(2),
saddress varchar2(100),
cid number references tclass(cid)--建立外键关系
);

create table tclass
(
cid number primary key,
cname varchar2(20)
);
--唯一unique 检查 check 默认值 modify 添加外键关系 添加列
alter table student1 add constraint UQ_student1_sname unique(sname);
alter table student1 add constraint CK_student1_agae check(sage between 19 and 70);
alter table student1 modify ssex default \'男\';
alter table student1 add constraint FK_student1_cid foreign key(cid) references tclass(cid);
alter table student1 add dt date;
--删除约束
alter table student1 drop constraint UQ_student1_sname ;

 

分类:

技术点:

相关文章:

  • 2021-11-28
  • 2022-01-15
  • 2021-10-18
  • 2021-12-12
  • 2021-12-29
  • 2021-05-31
  • 2021-08-18
  • 2021-12-08
猜你喜欢
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-12-30
  • 2021-11-28
  • 2021-11-20
相关资源
相似解决方案