【oracle】 表名,表字段,表空间等的操作

前端之家收集整理的这篇文章主要介绍了【oracle】 表名,表字段,表空间等的操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.修改表名

@H_502_3@

rename  prevIoUs_tableName to  new_tableName
@H_502_3@

2.给表新增一个字段

@H_502_3@

alter table [tableName] add [columnName] [columnType]

--i.e
alter table vst_event_index add  place_code number(20)

@H_502_3@

3. 删除一个字段

@H_502_3@

ALTER TABLE table_name 
DROP COLUMN column_name

--i.e

alter table VST_COMMENT   -- 删除 id
drop column id
@H_502_3@ @H_502_3@

@H_502_3@

4. 修改表字段类型

4.1 表中无数据 ,或者修改后的类型与之前类型兼容的前提下@H_502_3@

ALTER TABLE table_name
MODIFY (column_name datatype)

--i.e
alter table VST_COMMENT  --修改 id 类型 varchar2(30)→number(30)
modify (id number(30));
@H_502_3@ @H_502_3@ @H_502_3@

@H_502_3@

5.给表字段添加备注

@H_502_3@

comment on column [tableName].[columnName] is '[comments]'

--i.e

comment on column vst_event_index.place_code is '地点代码'
@H_502_3@

6. 修改表的表空间

@H_502_3@

alter table [tablespace].[tableName] move tablespace [another_tablespace]

---i.e

alter table vst_user_timeline move tablespace perp  -- 从默认的 users 表空间 转移到 perp 的表空间
@H_502_3@ @H_502_3@

4.

原文链接:https://www.f2er.com/oracle/213197.html

猜你在找的Oracle相关文章