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;