--建一個表
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 ;