数据库复习总结

Oracle数据库管理与优化

模式

  模式可以拥有数据库中的一切对象,如表,索引,视图,序列,同义词

   不同的模式可以建立相同的对象名

   一个模式只能指定一个默认的表空间

a)         表是以数据行为单位存储于数据块中的,oracle会尽量把同一笔数据放入一个数据块中。

b)        数据行

                        i.              行链接的产生:当数据行的数据内容超过了一个数据块时,内容放到了多个数据块

                      ii.              行迁移的产生:当一笔数据行被修改时,使得数据的内容超过了一个数据块的大小时

                    iii.              Oracle会把这笔数据转移到其他的数据块中存储。

                     iv.              数据行的组成:row header 记录共有多少数据行,,数据行锁与锁链的信息

1.         Row data  存放数据的地方,同时也记录数据行的长度。

c)         数据列

                        i.              四大类的数据类型:字符数据,大型对象数据,数值型,日期型和其他型

d)        ROWID

                        i.              作用是:使得使用者很容易就能查到所需要的数据

2.         形式是:虚拟字段,存在于索引里,动态产生,只能用于查询,不能用于增加,修改 删除

                        i.              查询ROWIDselect column1 ,rowid from test_user.test;

                      ii.              组成:数据文件编号,相对文件编号,块编号,行编号

b)        创建表

                        i.              赋予创建表的权限

                      ii.              Grant create table to user_test;

c)         删除表

                        i.              Drop table user_test.table_name;

d)        级联删除

                        i.              Drop table user_test.table_name cascade constrints;

e)         修改表名

                        i.              Alter table user_test rename to test_user;

f)         修改字段

                        i.              Alter table user_test rename column columno1 to columno2;

                      ii.              截断表

                    iii.              Truncate table test.table_name default / resuse;

                     iv.              Default 表示先删除表在重建,先释放所有的表空间,然后重建

                       v.              Reuse:清除后保留原来的空间。

                     vi.              截断的数据无法复原的。

 

 

 

g)        删除一个字段

                        i.              Alter table test.test_table drop column  comments cascade constrants checkpoint 1000;

h)        删除多个字段

                        i.              Alter table test.test_table drop(column  1, column2);

i)          删除字段的限制

                        i.              不能对一个表的所有字段进行删除

                      ii.              不能删除分区表的字段

                    iii.              不能删除索引组织表上主键所在的字段

3.         将一个字段设成不可用状态

                        i.              Alter table test.test_table set unused column1 comments cascade constraints;

4.         设定多个字段不可用     

                        i.              Alter tabel test.test_table set unused (column1, column2);

5.         删除不可用的字段

                        i.              Alter table test.test_table drop unused columns checkpoint 1000;

 

6.         修改字段

                        i.              Alter table test.test_table rename column column3 to column1;

7.         修改字段的类型

                        i.              Altert table test.test_table modify column char(1);

视图

  使用SQL的查询语法且针对表所定义出来的虚拟数据表

   创建视图

      Create or replace view test.V_test_table as select a.column1, a.column2, from tesst.test_table01 a;

索引

   作用是:帮助使用者快速的找到数据。

    组成是:index entry header ; key column length-value; rowid

 

   

        

 

用户

1.         用户:没有拥有任何对像的账户

2.         模式:拥有了对象的账户

3.         用户及用户的管理

4.         授予创建用户的权限

                        i.              Grant create user to test_user;

5.         创建用户要指定四个内容

                        i.              Create user test_user

1.         Indentified by “test” //登陆密码

2.         Default tablespace tablespace_name

3.         Temporary tablespace temp_tablespace

4.         Quota 500 M on tablespace_name

5.         Profile profile_name;

6.         授予连接的权限给用户

                        i.              Grant connect to test_user;

7.         修改用户

                        i.              Alter user test_user

1.         Indentified by “test”

2.         Default tablespace tablespace_name

3.         Temporary tablespace temp_tablespace

4.         Quota 500 M on tablespace_name

5.         Profile profile_name;

8.         删除用户

                        i.              Drop user test_user;

9.         如果该用户有对象,则需要级联删除

                        i.              Drop user test_user cascade;

10.     查询用户

                        i.              Select * from dba_users;

角色

1.         定义:权限的集合

2.         授予创建用户的角色

a)         Grant create role to user_test;

3.         创建角色

a)        Create role user_test/indentified by “text”/indentified by extrnally;

4.         删除角色

a)         Drop rele user_text;

5.         修改角色

a)        Alter role user_test/indentified by “text”/indentified by extrnally;

6.         将角色分配给用户

a)         Alter role user_test to user_test;

7.         将默认角色分配给用户

a)         Grant resource to pdw01 with admin option;

8.         回收用户的角色

a)         Revoke user_test from user_test;/

9.         查询用户

                        i.              Select * from dba_roles;

 

数据库字典

1.         定义:数据库字典是一些只读的表与视图组成的,在数据字典里的对象都是属于SYS所拥有的。

2.         查询数据字典

3.         Select * from dictionary;

动态性能视图

a)         定义:记录目前数据库的运作状态,会在数据库开启后不断更新相关的信息,这些信息包括,oracle 内存使用状态,数据库运作状态, 控制文件。

b)        注意点:

                        i.              动态视图是以V$ 开头的,如:V$DATABASE

                      ii.              只能读取

                    iii.              动态性能视图里德信息都是小写的,而数据库字典的信息都是大写的。

                     iv.              随时更新的

 

 

系统权限和对象权限的区别:撤销系统权限是无级联反应,对象特权是在指定的表,视图,序列,函数等上执行特殊动作的权利。常见的系统特权:create session , create table,对象特权:alter ,delete, execute, index,insert.select.updata. 角色:connect,dba. Resource.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值