Oracle1

数据库结构(重点)

数据库结构(重点)

       默认用户:

      scott:普通用户,是Oracle一个示范用户,主要用于用户学习

      System:普通用户,但授予了DBA角色

      Sys:管理员用户,具有Oracle服务器中最高权限

创建用户的语法:

create user yx identified by 123456;

删除用户:(cascade表示连同该用户的所有对象全部级联删除,如果在用户下有数据库对象,必须使用cascade)

drop user yx cascade;

修改密码:(新密码为123456)

alter user identified by 123456;

给用户授权:

grant dba to yx; 给用户授予管理员权限

grant connetion to yx; 允许用户连接数据库,并创建数据库对象

grant resource to yx; 允许用户使用数据库中的存储空间

grant create sequence to yx; 允许用户在当前模式中创建序列,此权限包含在connection角色中

grant select on scott.emp to yx;  允许用户查询scott.emp表的记录

grant update on scott.emp to yx;允许用户更新scott.emp表的数据

grant all on scott.emp to yx; 允许用户更新,查询,删除,插入表的记录

撤销授予的权限(revoke)

revoke all on scott.emp  from yx; 撤销用户可以查询,插入scott.emp等中记录

revoke update on scott.emp from yx; 撤销用户可以更新scott.emp表数据的权限

创建表空间(表都存储在表空间中,利于对表空间授予权限)

create tablespace yuxi_space()

创建表区(表名:customer)

Create table customer(

   stu_id   number(4,0) , 小数位最多0位,整数位最多4位

   stu_name   varchar2(8) , 姓名的字符最多为8,小于8的时候自动变短

   stu_sex   varchar(4) ,性别的字符为4个字节

   stu_card   number(8),

   birthday   date

);

表中的权限

alter table customer add constraint pk_id primary   key(stu_id) –主健约束

alter table customer add constraint pk_sex check(stu_sex=’男’ or stu_sex=’女’)—检查约束

Alter table customer modify(stu_name not null) --非空约束

Alter table customer modify birthday default sysdate--默认约束

Alter table customer add constriant up_card unique(stu_card)唯一约束

创建表的同时,给表赋予权限(当表中的权限不发生重复)

Create table student(

   Stu_id number(6) primary key,

Stu_name   varchar2(8) not null,

Stu_sex   varchar(4) check(stu_sex=’男’ or stu_sex=’女’),

Stu_card   number(8) unique(stu_card),

Birthday   date default sysdate

);

对表的一些修改操作

删除表(表名student)

Drop table student();

重命名表(将表名customer换成cus)

Rename table cus to customer;

增加字段

Alter table student add(stu_card char(18));

删除字段(删除stu_birth行)

Alter table student drop column stu_birth;

 

                       

转载于:https://www.cnblogs.com/yuxi12/p/7976013.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值