Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91929543
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-30 19:12:38




       end;
26、用户管理
 create a user: database authentication
  sql> create user juncky identified by oracle default tablespace users
  sql> temporary tablespace temp quota 10m on data password eire
  sql> [account lockunlock] [profile profilenamedefault];

 <1>.查看当前用户的缺省表空间
 SQL>select username,default_tablespace from user_users;
 <2>生成用户时指定缺省表空间
  create user 用户名 identified by 口令  default      tablespace 表空间名;
  
 <3>重新指定用户的缺省表空间
      alter user 用户名 default tablespace 表空间名
 <4>查看当前用户的角色
 SQL>select * from user_role_privs;
 <5>查看当前用户的系统权限和表级权限
  SQL>select * from user_sys_privs;
  SQL>select * from user_tab_privs;
 <6>查看用户下所有的表
      SQL>select * from user_tables;
 <7> alter user语句的quota子句限制用户的磁盘空间
     如:alter user jf  quota 10M  on system;


27、查看放在ORACLE的内存区里的表  
     SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;

28、约束条件
    create table employee
     (empno  number(10)  primary key,
      name   varchar2(40) not null,
      deptno  number(2)  default 10,
      salary  number(7,2)  check  salary<10000,
      birth_date date,
      soc_see_num  char(9)  unique,
      foreign key(deptno) references dept.deptno)
      tablespace users;
     
    关键字(primary key)必须是非空,表中记录的唯一性
    not null  非空约束
    default   缺省值约束
    check     检查约束,使列的值符合一定的标准范围
    unqiue  唯一性约束
    foreign key 外部键约束

29、查看创建视图的select语句
     SQL>set view_name,text_length from user_views;
     SQL>set long 2000;  说明:可以根据视图的text_length值设定set long 的大小
     SQL>select text from user_views where view_name=upper('&view_name');

30、查看同义词的名称
     SQL>select * from user_synonyms;

31、用Sql语句实现查找一列中第N大值
select * from
(select t.*,dense_rank() over (order by sal) rank from employee)
where rank = N;

32 虚拟自段
  <1>. CURRVAL 和 nextval
   为表创建序列
   CREATE SEQUENCE EMPSEQ ... ;

阅读(389) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~