oracle(2) : 基础命令

参考 : 

    https://www.cnblogs.com/xielong/p/8950999.html

    https://blog.csdn.net/starnight_cbj/article/details/6792364

oracle版本 : Release 11.2.0.1.0

docker版本 : Docker version 19.03.8, build afacb8b

创建用户及授权(创建用户名和密码都为test)

create user test identified by test;
grant connect,resource,dba to test; 

查询所有表空间

select name from v$tablespace;

查询用户下所有表

select table_name from user_tables;

创建表空间

create tablespace ts_test  datafile '/data/oracle/test.dbf'  size 1500M autoextend on next 5M maxsize 3000M;

创建表

create table Student(
    stuId number(9) not null,
    stuName varchar2(20) not null,
    stuMsg varchar2(50) null
);

创建自增序列

 create sequence Student_stuId_Seq
 increment by 1
 start with 1
 minvalue 1
 maxvalue 999999999;

插入数据

insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n1');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n2');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n3');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n4');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n5');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n6');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n7');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n8');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n9');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n10');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'n11');

查询表数据

select * from student;

清空表

truncate table student;

删除表

drop table student;

查看表结构

desc student;

删除表空间

DROP TABLESPACE ts_test INCLUDING CONTENTS AND DATAFILES;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值