oracle 中更改表的結構語句

2021-04-22 03:59:50 字數 1051 閱讀 3728

修改乙個列的資料型別(一般限於修改長度,修改為乙個不同型別時有諸多限制):

語法:    alter table 表名 modify(列名 資料型別);

eg1:   alter table skate_test modify (author number(10,0) )

在修改列的長度時候,只能編輯比現有字段實際存的長度還要大,否則提示下面的錯誤:

ora-01441: 無法減小列長度, 因為一些值過大

eg2:    alter table skate_test modify (author varchar2(10) )

在修改列的資料型別的時候,所修改的列必須為空,否則提示下面的錯誤:

ora-01439: 要更改資料型別, 則要修改的列必須為空

2.增加乙個列:

語法:      alter table 表名 add(列名 資料型別);

eg1:     alter table skate_test add(author number(38,0) not null);

3.給列改名:

語法:     alter table 表名 rename column 當前列名 to 新列名;

eg1:     alter table skate_test rename column author to authorer_new

4.刪除乙個列:

語法:    alter table 表名 drop column 列名;

eg1:    alter table skate_test drop column author

5.將乙個表改名:

語法:   alter table 當前表名 rename to 新錶名;

eg1:   alter table skate_test rename to test_sakte

6.給表加注釋:

語法:comment column on 表名.列名 is '注釋內容';   //修改表的列的注釋

eg1:comment on table movo_new.test_sakte  is '注釋內容';  //修改表的注釋

oracle語句匯出表結構

在plsql中直接執行 select t.table name,t.column name,t.data type t.data length t1.comments from user tab cols t,user col comments t1 where t.table name t1.ta...

Oracle查詢表結構的SQL語句

1.查詢表結構基本資訊 select from user tables t,user tab comments c where c.table name t.table name andt.table name 表名 2.查詢表的所有列及其屬性 select t.column name,t.data...

DB 更改表結構

在 3 小節和 2 小節 中都對mysql建立表有個清晰的認識,那麼現在就學習如何更改表結構。一 快速入門 通過乙個例子進行深入理解,這裡a1表結構如下 下面的例子對a1的表結構進行更改 1 新增字段 alter table a1 add column s1 int notnull default ...