加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle Database之表基本操作(DDL)

发布时间:2020-12-12 15:37:25 所属栏目:百科 来源:网络整理
导读:本文详细介绍了Oacle数据库中表的基本操作: 如何创建数据库表 --方法1: 用create table创建表 create table ods_user_inf(user_id number,user_num varchar2(20),user_name varchar2(30),nickname varchar2(30),status varchar2(10),gender varchar2(1),bir

本文详细介绍了Oacle数据库中表的基本操作:

如何创建数据库表

--方法1: 用create table创建表

create table ods_user_inf
(
	user_id number,user_num varchar2(20),user_name varchar2(30),nickname  varchar2(30),status  varchar2(10),gender  varchar2(1),birthday date,email varchar2(50),telephone varchar2(20),mobile varchar2(20),address varchar2(300),department_id number
);

--方法2: 基于现有表创建表结构
create table ods_user 
as 
select *
from ods_user_inf
where 1=2;

如何重命名数据库表名

alter table ods_user_active rename to ods_user_effective;

如何添加数据库表备注

comment on table ods_user_inf is 'The table is created to store the user information';
--查看备注:
select * from user_tab_comments where comments is not null;

如何删除表

drop table ods_user_inf_active;

如何增加数据库表列

alter table ods_user_inf  add (salary number(22,2),bonus number(22,2));
alter table ods_user_inf  add (type varchar2(20));
alter table ods_user_inf  add (attribute1 varchar2(20));
alter table ods_user_inf  add (attribute1 varchar2(20));

如何修改数据库表列名

alter table ods_user_inf rename column type to user_type; 

如何修改数据库表列类型

alter table ods_user_inf modify user_type varchar2(25); 

如何增加数据库列备注

comment on column ods_user_inf.user_num is 'user number';

--查看备注:

select * from user_col_comments where comments is not null and table_name='ODS_USER_INF';

如何删除数据库表中的列

alter table ods_user_inf drop column attribute2;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读