Oracle创建表和创建序列和修改,增加sql字段

一。创建表

  create table y_parts_classify(

    pt_id number(10) not null,

    pt_name varchar2(1000),

    update_time date default sysdate,

    create_time date default sysdate

  )

二。修改,和增加,删除sql字段

  alter table y_parts_classify modify(

    pt_name varchar2(800)

  )

  alter table y_parts_classify add(

    remark varchar2(1000)

  )

 

  删除字段的语法:alter table tablename drop (column);

    说明:alter table 表名 drop column 字段名;

       例:alter table sf_users drop column HeadPIC;

三。Oracle给字段增加说明。备注

  语法:comment on column TableName.ColumnName is '备注'

  例子:comment on column y_parts_classify.pt_id  is '配件分类id'

四。Oracle创建序列

  create sequence seq_parts_classify 

  minvalue 1

  nomaxvalue 

  start with 1

  increment by 1 

  nocycle

  nocache

五,从虚拟表查询

  select seq_parts_classify.nextval from dual 

六.字段和表的重命名

字段的重命名:

说明:alter table 表名 rename  column  列名 to 新列名   (其中:column是关键字)

   例:alter table sf_InvoiceApply rename column PIC to NEWPIC;

 

表的重命名:

说明:alter table 表名 rename to  新表名

   例:alter table sf_InvoiceApply rename to  sf_New_InvoiceApply;

 

posted @ 2018-07-30 12:50  梦浍烈风灵  阅读(7452)  评论(0编辑  收藏  举报