說明:想增加或刪除欄位、調整欄位長度或名稱時,該怎麼做?
語法:
1. 增加欄位:ALTER TABLE table_name ADD column_name column-definition;
例:ALTER TABLE account ADD user_id VARCHAR2(10);
2. 刪除欄位:ALTER TABLE table_name DROP COLUMN column_name;
例:ALTER TABLE account DROP COLUMN user_id;
3. 調整欄位:ALTER TABLE table_name MODIFY column_name column-definition;
ALTER TABLE table_name MODIFY
(column_name1 column-definition,
column_name2 column-definition);
例:ALTER TABLE account MODIFY user_id VARCHAR2(20);
4. 調整欄位名稱:ALTER TABLE table_name RENAME COLUMN old_name to new-name;
例:ALTER TABLE account RENAME COLUMN user_id to user;
參考資料:
http://www.techonthenet.com/sql/tables/alter_table.php
http://www.dba-oracle.com/t_alter_table_modify_column_syntax_example.htm
http://www.dotblogs.com.tw/dc690216/archive/2011/02/23/21534.aspx
http://docs.oracle.com/cd/E17952_01/refman-5.0-en/alter-table.html
http://blog.xuite.net/f8789/DCLoveEP/43020770-PLSQL+%26+SQL+-+%E4%BF%AE%E6%94%B9%E8%B3%87%E6%96%99%E8%A1%A8%E4%B8%AD%E7%9A%84%E6%AC%84%E4%BD%8D%E9%95%B7%E5%BA%A6
沒有留言:
張貼留言