oracle-1 表的基本操作

1、创建表

create table student (idnumber(4) not null,namenvarchar2(4),birth date)

2、修改表

1)修改表名

alter table student renameto stu;

2)修改字段名

alter table stu renamecolumn birth to birthdate;

3)修改字段类型等

alter table stu modifyid varchar2(4);

alter table stu modifyid varchar2(4) null; (将字段修改为可以为空)

4)添加字段

alter table stu addage number(4);

5)删除字段(字段没有值)

alter table stu dropcolumn age;

alter table stu drop  (id ,birthdate);

注:删除单列要加COLUMN,删除多列不能加COLUMN

3、删除表

drop table stu;--删除内容和定义

truncate table student; --:删除内容、释放空间但不删除定义

delete  student;--删除内容不删除定义,不释放空间

http://www.cr173.com/html/40708_1.html 

4、向表中插入数据

insert into student values(1,'zh',to_date('2017-12-31'));

5、复制表

1)复制表结构及数据

create table stu as select * from a

2)只复制表结构

create table stu as select * from student where 1=2;

注:以上若是只想复制部分字段,可以在select后面选中需要的字段

create table stu as select id,name from studentwhere 1=2;

3)只复制表数据

insert into stu select * from student;

insert into stu select id,name fromstudent;(stu结构只有id和name两个字段)

insert into stu(id) select idfrom student;

insert into stu select *from c whererownum <4;--可以选择行数






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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值