SQL中表示最基本的数据库对象,由行和列组成,这篇文章介绍对于表对象的创建和管理,如有不当或错误的地方,还望各位大神们批评指正。
select * from user_tables
select distinct object_type from user_objects ;
必须以字母开头 必须在1-30个字符之间 只能包含a-z,A-Z,0-9,_、$ 和 # 不能与用户定义其他对象重名 不能与系统保留字段重名
不依托于任何表
create table table1( id number(6) , name varchar(200) , salary number (10,2) , birthday date )
依托于现有表,且复制原有数据
create table table2 as select id , name , birthday ,salary from table1 ; --若不需要原有表中的条件则加入where过滤一个假条件如where 0=1
先在表结构中添加一个el字段,长度为20,类型为number,可为空 (ADD);
alter table table1 add( u_tel number(20) )
将tel字段中的字段长度修改为11(MODIFY);
alter table table1 modify( u_tel number(11) )
注:修改表中字段类型时,表中数据必须为空
删除tel字段(DROP);
alter table table1 drop( u_tel )
重命名字段salary为sal
alter table table1 rename column sal to salary ;
删除表table1
drop table table1 ;
delete from table1 ;