oracle 表基本操作,Oracle Database之表基本操作(DDL)

本文详细介绍了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;

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值