oracle表字段的增加刪除和修改

2021-07-22 08:27:39 字數 1251 閱讀 9162

oracle表字段的增加刪除和修改

--增加字段

alter table luffy.student_test2 add (cdr_content varchar2(2000));

alter table luffy.student_test2 add (course_inst_id number(12));

alter table luffy.student_test2 add address varchar2(40);

--刪除字段

alter table luffy.student_test2 drop column cdr_content;

alter table luffy.student_test2 drop column prod_inst_id;

alter table luffy.student_test2 drop column address ;

--修改字段長度和型別

alter table luffy.student_test2 modify(id number(7));--將字段長度改為7

alter table luffy.student_test2 modify id number(20);--將字段長度改為20

alter table luffy.student_test2 modify(id varchar2(8));--將字段型別由number改為varchar2,長度為8,(要更改型別,需要修改的列必須為空)

alter table luffy.student_test2 modify id varchar2(20);--將字段型別由number改為varchar2,長度為20,(要更改型別,需要修改的列必須為空)

--修改欄位名稱

alter table luffy.student_test2 rename column id to stu_id;

alter table luffy.student_test2 rename column stu_id to id;

--修改表名稱

alter table luffy.student_test2 rename to student_test22;--修改表名

rename luffy.student_test22 to student_test2; --不允許指定表的所屬使用者

--查詢某使用者下所有的表

select * from dba_tables where owner='esb_test';

Oracle表字段的增加 刪除 修改和重新命名

本文主要是關於oracle資料庫表中字段的增加 刪除 修改和重新命名的操作。增加字段語法 alter table tablename add column datatype default value null not null 說明 alter table 表名 add 欄位名 字段型別 預設值 ...

Oracle表字段的增加 刪除 修改和重新命名

本文主要是關於oracle資料庫表中字段的增加 刪除 修改和重新命名的操作。增加字段語法 alter table tablename add column datatype default value null not null 說明 alter table 表名 add 欄位名 字段型別 預設值 ...

Oracle表字段的增加 刪除 修改和重新命名

本文主要是關於oracle資料庫表中字段的增加 刪除 修改和重新命名的操作。增加字段語法 alter table tablename add column datatype default value null not null 說明 alter table 表名 add 欄位名 字段型別 預設值 ...