模式
模式可以擁有資料庫中的一切物件,如表,索引,檢視,序列,同義詞
不同的模式可以建立相同的物件名
乙個模式只能指定乙個預設的表空間
表
a)表是以資料行為單位儲存於資料塊中的,
oracle
會盡量把同一筆資料放入乙個資料塊中。
b)資料行
i.行鏈結的產生:當資料行的資料內容超過了乙個資料塊時,內容放到了多個資料塊
ii.行遷移的產生:當一筆資料行被修改時,使得資料的內容超過了乙個資料塊的大小時
iii.
oracle
會把這筆資料轉移到其他的資料塊中儲存。
iv.資料行的組成:
row header
記錄共有多少資料行,,資料行鎖與鎖鏈的資訊
1.row data
存放資料的地方,同時也記錄資料行的長度。
c)資料列 i.
四大類的資料型別:字元資料,大型物件資料,數值型,日期型和其他型
d)rowid i.
作用是:使得使用者很容易就能查到所需要的資料
2.形式是:虛擬字段,存在於索引裡,動態產生,只能用於查詢,不能用於增加,修改
刪除i.
查詢rowid
:select 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 columncomments cascade constrants checkpoint 1000; h)
刪除多個字段
i.alter table test.test_table drop(column1, 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.
資料庫複習總結
本課程主要講的就是資料庫設計的問題。主要包括模型的設計,儲存方式的設計,以及核心的設計 查詢功能 事務管理器 事務併發控制的實現 首先在設計模型的時候可以分為三層來看,檢視層 邏輯層和物理層,物理層是資料庫管理者也就是像oracle這樣的大型資料庫公司關係的事情,不需要考慮使用者的感受因為這個不是面...
資料庫複習總結
這次學習的課程是面向面試的,所以很多知識都是根據面試 現的高頻問題來學習的.這個是乙個很空泛很大的問題,但是我們可以將資料庫的構建和乙個軟體的構建進行模擬 首先需要硬體儲存模組,比如 機械硬碟,固態硬碟等來儲存資料 資料庫程式例項 資料僅僅儲存起來是沒有任何意義的,需要對資料庫中的資料進行操作,比如...
資料庫複習總結(21) 索引
索引 專案大中後期才用 1 是什麼?相當於書的目錄,字典的檢索,實現了資料的快速查詢 2 分類 聚集索引 與實際儲存位置一樣,乙個表中只能有乙個聚集索引,主鍵採用聚集索引 非聚集索引 索引順序與儲存順序不一致。如學生在教室中的位置,可以按年齡進行查詢,也可以按身高進行查詢 3 建索引 介面 右擊表 ...