好长时间没有用oracle了,感觉用起来连最基本的都写得不太自信了,所以抽空回忆了一下,以后慢慢总结:
--1.创建表空间
create tablespace userMag datafile 'd:\userMag.ora' size 10M autoextend on next 1M --autoextend on next 设定自动增长值
--2.创建用户
create user admin identified by aaa default tablespace userMag;--identifeied by 设置密码
--3.授权用户
grant connect,resource to admin;--授权连接、资源权利
--4.创建表
create table userinfo(
id number(10) not null primary key,
name varchar2(20),
password varchar2(20)
)
--5.创建序例
create sequence For_test
increment by 1 --从1开始
start with 1 --步进长为1
maxvalue 999999999 --最大值为999999999
nocycle --CYCLE在有最大值时,达到最大值99999999999后循环从1开始再次递增,NOCYCLE不循环
cache 10;--缓存,默认为20
--6.插入数据
insert into userinfo values(For_test.Nextval,'aaa','aaaa');
insert into userinfo values(For_test.Nextval,'bbb','bbbb')