Oracle数据库对象——表

在关系型数据库中,表被看作一个关系,表中的每个列是关系中的属性,是一个不可再分割的基本单位,表中的行对应一个元组。

①、创建表

create table <表名>(<列名><数据类型>[约束]);

数据类型:

SCOTT@myh>create table stu (id number(12) primary key,
  2  name varchar(20),
  3  age number(3));

#通过子查询的方式创建表:

SCOTT@myh>create table test as select * from dept;

②、表的修改

#增加列   关键字add
SCOTT@myh>alter table stu add (tel number(11));

Table altered.

#删除列   关键字drop
SCOTT@myh>alter table stu drop column age;

Table altered.

#修改列的定义    关键字modify
SCOTT@myh>alter table stu modify (id number(4));

Table altered.

#将一个列设置为不可用   关键字set unused。设置为unused的列虽然逻辑上看不到,但是物理上是存在的。
#然后再删除不可用列。
SCOTT@myh>alter table stu set unused column tel;

Table altered.

#修改列名    关键字 rename column <> to <>
SCOTT@myh>alter table stu rename column name to stu_name;

Table altered.

#将表设置为只读状态
SCOTT@myh>alter table stu read only;

#设置为可写状态

SCOTT@myh>alter table stu read write;

③、表的删除,将表结构和表数据全部都删除。

SCOTT@myh>drop table stu;

Table dropped.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值