oracle表的创建、删除、修改、查询语句

oracle表的创建、删除、修改、查询语句

1、创建表

1.1 创建表

语法:
create table 表名
(
  字段1         类型1 主键,
  字段2         类型2 默认 非空,
  字段3         类型3 非空
);

例句:
create table student
(
  id            VARCHAR2(40) primary key,
  name          VARCHAR2(20) default '小米' not null,
  age         	VARCHAR2(20) not null
);

1.2 复制一张表,包含字段,数据

create table 新表名 as select * from 旧表名;
create table student1 as select * from student;

1.3复制一张表,包含字段,不含数据

create table 新表名 as select * from 旧表名 where 1=2;
create table student1 as select * from student where 1=2;

2、删除表

2.1 删除表,删除结构、数据

drop table 表名;
drop table student1;

2.2 删除表,删除结构、不删除数据

truncate table 表名;
truncate table student1;

3、修改表

rename 旧表名 to 新表名;
rename student to student1;

4、查询表

//查看当前登录的用户的表名:
select table_name from user_tables;
//查看当前登录的用户表所有属性:
select * from user_tables;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值