• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
土上方方
博客园    首页    新随笔    联系   管理    订阅  订阅

表空间,序列

表空间

首先用system登录,对用户授权

grant create,drop tablespace to HAPPYY2165


create tablespace y2165tabspace
datafile 'E:\app\Happy\oradata\orcl\y2165tabspace_1.dbf' size 10m,
'E:\app\Happy\oradata\orcl\y2165tabspace_2.dbf' size 10m
 autoextend on next 32m maxsize unlimited


 
 select tablespace_name from user_tablespaces; 


--删除表空间
drop tablespace y2165tabspace2
--删除表空间的同时清除物理文件
drop tablespace y2165tabspace including contents and datafiles
序列

 序列和表是平级的。

 序列是用于生成唯一,连续序号的对象,序列可以是升序的,也可以是降序的,使用 create seqvence语句创建序列。

 create tablespace y2165tabspace
datafile 'E:\app\Happy\oradata\orcl\y2165tabspace_1.dbf' size 10m 
 autoextend on next 32m maxsize unlimited
 --Oracle没有自增列 ,用的就是序列
 create table dept
 (
   deptno number primary key not null,
   deptname nvarchar2(32)
 ) tablespace  y2165tabspace
 
 
  create table emp
 (
   empno number primary key not null,
   empname nvarchar2(32)
 ) tablespace  y2165tabspace
 
  insert into dept values(1,'开发部')
  commit
  select * from dept
  
   insert into emp values(1,'啦啦')
   insert into emp values(seq_num.nextval,'啦啦')
  commit
  select * from emp


  insert into dept values(seq_num.nextval,'开发部')
  
  select  seq_num.nextval from dual;


    --当前序列中存储的值是多少
    select  seq_num.currval from dual;
   --GUID和UUID 
   
   select SYS_GUID() from dual;

posted @ 2017-09-18 22:11  土上方方  阅读(174)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3