添加表中的列
ALTER TABLE major ADD majorRank number(3);
ALTER TABLE major ADD createDate DATE DEFAULT SYSDATE NOT NULL;
ALTER TABLE major ADD peopleNum number(4) CONSTRAINT ck_peopleNum CHECK(peopleNum > 30);
查看表中的列:
SELECT * FROM USER_TAB_COLS WHERE TABLE_NAME = 'MAJOR';
删除列:
ALTER TABLE major DROP COLUMN majorRank;
ALTER TABLE major DROP (majorRank,peopleNum);
重命名列:
ALTER TABLE major RENAME COLUMN createDate TO foundDate;
设置列为UNUSED:
ALTER TABLE major SET UNUSED COLUMN foundDate;
ALTER TABLE major SET UNUSED (majorRank,CreateDate,peopleNum);
删除表:
DROP TABLE major;
恢复被删除的表
FLASHBACK TABLE major TO BEFORE DROP;
根据另外一个表创建表
CREATE TABLE newTable AS SELECT * FROM STUDENT;
添加表和列的注释
COMMENT ON TABLE newTable is ‘Copy student struct’;
SELECT * FROM user_tab_comments where table_name = 'NEWTABLE';
COMMENT ON COLUMN newTable.studentID is 'Copy student.studentID';
SELECT * FROM user_col_comments where table_name = 'NEWTABLE';
删除表:
DROP TABLE newTable;
清空回收站:
PURGE RECYCLEBIN;