oracle建表,设置主键,修改属性等
--建表 create table book( book_id number(10), book_name varchar2(20), book_price number(10,2), book_author varchar2(20), book_publish_time date, book_introduction varchar2(100) );
--设置主键 constraint :约束 alter table book add constraint PK_ID primary key (book_id); --添加和删除列 alter table book add book_remark varchar2(20); alter table book add( book_ext1 varchar2(20), book_ext2 varchar2(20) );
alter table book drop column book_ext1; --修改表名称 alter table book rename to new_book; alter table new_book rename to book; --修改列名称 alter table book rename column book_name to book_name_new; alter table book rename column book_name_new to book_name ; --修改字段属性类型 alter table book modify book_name varchar2(40); --修改字段属性默认值 alter table book modify book_name default 'green tale'; --删除表 drop table book;
建表时的参数:
create table AB_XIAOFSWJLB ( ID VARCHAR2(90) not null, MINGC VARCHAR2(90) not null, XIEZBM VARCHAR2(90) not null, SHIWNR VARCHAR2(1024) not null, RIQ CHAR(14) not null, BEIZ VARCHAR2(300), GUANLRYJ VARCHAR2(300), SHENCRID VARCHAR2(90), SHENCR VARCHAR2(90), SHENCZT VARCHAR2(90), SHENCRQ CHAR(14), JILRID VARCHAR2(90), JILR VARCHAR2(90), JILRQ CHAR(14), CORPID VARCHAR2(90) not null, DEPID VARCHAR2(90) not null ) pctfree 10 initrans 1 storage ( initial 64K minextents 1 maxextents unlimited ) tablespace USERS logging;
http://blog.itpub.net/17203031/viewspace-688011/
We only live once, and time just goes by.