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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM