oracle alter table
时间: 2023-04-15 12:01:08 浏览: 168
Oracle的alter table语句用于修改已经存在的表的结构,可以添加、删除、修改表的列、约束、索引等。
常见的alter table语句包括:
1. 添加列:ALTER TABLE table_name ADD column_name data_type;
2. 修改列名和数据类型:ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name, MODIFY new_column_name new_data_type;
3. 删除列:ALTER TABLE table_name DROP COLUMN column_name;
4. 添加主键:ALTER TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY (column_name);
5. 添加外键:ALTER TABLE table_name ADD CONSTRAINT constraint_name FOREIGN KEY (column_name) REFERENCES referenced_table_name (referenced_column_name);
6. 添加索引:ALTER TABLE table_name ADD INDEX index_name (column_name);
7. 删除索引:ALTER TABLE table_name DROP INDEX index_name;
8. 修改表名:ALTER TABLE old_table_name RENAME TO new_table_name;
9. 修改表的存储参数:ALTER TABLE table_name STORAGE (initial_size next_size max_size);
等等。
阅读全文