设计表
设计一张表应该从 表明,字段,约束,类型,表于表之间的关系去考虑。
应该符合三范式
创建表
语法 create table 【表名】{
【字段】 【字段类型】,
【字段】 【字段类型】,
……
}
create table student(
id number(10),
name varchar2(15),
age number(3)
)
删除表
drop table 【表名】
-drop table student;
如果表有主外键约束时候,需要先删除主表,再删除从表
或者使用cascade constraints 来解除约束并删除表
drop talbe 【表名】 cascade constraints
-drop table emp_his2 cascade constraints;
拷贝表
拷贝表结构
create table 【表名】 as 【结果集(空数据的结果集)】
-create table emp_his as select ename,sal from emp where 1!=1;
拷贝表结构加数据
create table 【表名】 as 【结果集(全部数据)】
-create table emp_his2 as select ename,sal from emp where sal>2000;
表注释
comment on table 【表名】 is 【注释】