首页 > 其他 > 详细

【考试】用户管理

时间:2016-11-21 23:08:57      阅读:221      评论:0      收藏:0      [点我收藏+]
1)创建一个用户名称为user1并授予权限至少能够访问hr.employees(不能授予dba权限)
SYS@ORA11GR2>create user user1 identified by user1;

User created.
SYS@ORA11GR2>grant create session,create table,create sequence,create view to user1;

2)用user1用户创建表students(学号 数值类型 主键约束stud_sno_pk,班级 字符类型外键参照班级表的班级列,姓名 字符类型 非空);
USER1@ORA11GR2>create table students
  2  (sno number constraint stud_sno_pk primary key,
  3  scno number(20),
  4  sname varchar2(20),
  5  constraint stud_scl_fk foreign key (scno) references classes (cno));

Table created.

3)用user1用户创建表classes(班级 数值类型 主键约束);
USER1@ORA11GR2>create table classes
  2  (cno number(5) constraint pk_cno primary key using index);

Table created.
4)模拟向以上两个表中插入数据,并且在数据字典中查询两个表的约束信息并显示。
USER1@ORA11GR2>insert into classes values(01);

1 row created.

USER1@ORA11GR2>insert into classes values(02);

1 row created.

USER1@ORA11GR2>insert into students values(1,01,zhangsan);

1 row created.

USER1@ORA11GR2>insert into students values(2,02,lisi);

1 row created.

USER1@ORA11GR2>select constraint_name,constraint_type,table_name
  2  from user_constraints
  3  where table_name=upper(students);
USER1@ORA11GR2>select constraint_name,constraint_type,table_name
  2  from user_constraints
  3  where table_name=upper(classes);

 

【考试】用户管理

原文:http://www.cnblogs.com/tomatoes-/p/6087196.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!