SQL增加、刪除、更改表中的字段名


1. 向表中添加新的字段

   alter  table  table_name  add  column_name  varchar2(20) not null

2. 刪除表中的一個字段

    delete table table_name column column_name

3. 修改表中的一個字段名

   alter table table_name rename column oldname to newname

4. 添加主鍵約束
   alter table 表名
   add constraint 約束名 primary key (列名)

5. 添加唯一約束
   alter table 表名
   add constraint 約束名 unique (列名)

6. 添加默認約束
   alter table 表名
    add constraint 約束名 default(內容) for 列名

7. 添加check約束
   alter table 表名
   add constraint 約束名 check(內容)

8. 添加外鍵約束
   alter table 表名
   add constraint 約束名 foreign key(列名) references 另一表名(列名)

9. 刪除約束
   alter table 表名
   drop constraint 約束名


免責聲明!

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



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