表空間表操作
總結
// 查詢表的基礎語句
select *
from tablename;
// 檢視路徑下有哪些表空間,表空間大小,以及本地存放路徑
select *
from dba_date_files;
//檢視表空間已經使用多少位元組
select *
from dba_free_space;
//檢視臨時表的空間大小等資訊
select *
from dba_temp_files;
//高階操作:檢視表空間剩餘的大小,以下倆個值相減即可,這樣寫法是為了更好的記憶
//檢視表空間共有多少位元組
select t.
tablespace_name
,sum
(t.bytes
/1024
/1024)mb
from dba_data_files t group by t.
tablespace_name
;//檢視表空間使用多少位元組
select t.
tablespace_name
,sum
(t.bytes
/1024
/1024)mb
from dba_free_space t group by t.
tablespace_name
;
// 檢視角色資訊
select *
from dba_roles;
// 檢視使用者資訊
select *
from dba_users;
// 查詢表名和對應的表描述
select *
from user_tab_comments;
// 查詢表字段和注釋
select *
from user_col_comments;
// 查詢表字段和型別
select *
from user_tab_columns;
// 使用者:系統許可權:建立資料庫,建立使用者,建立和維護表空間等
select *
from dba_sys_privs;
// 使用者:物件許可權:檢視,序列號,儲存過程。函式等
select *
from user_tab_privs_made;
// 角色:檢視角色授予資訊
select *
from dba_role_privs;
// 角色:檢視角色許可權
select *
from role_sys_privs;
// 查詢有那些儲存過程
select *
from dba_directories;
// 查詢使用者物件
select *
from user_objects ;
select *
from dba_ts_quotas;
// 建立tbs_01表空間大小10m,不自增,一般不設定自增,會給系統帶來不穩定性以及
create tablespace tbs_01 datafile 'e:\data\oracle\ta.d bf' size 10m autoextend off;
//建立tbs_02臨時表空間大小512m,每次增加256
create temporary talespace temp2 tempfile 『d
.dbf』 size 512m autoextend on next 256m
// 擴充套件表空間不自增
alter tablespace tbs_01 add datafile 'e:\data\oracle\taa.db' size 10m;
// 擴充套件表空間自增
alter tablespace tbs_01 add datafile 'e:\data\oracle\taa.db' size 10m autoextend on next 10m;
// 此處的7是表空間的file_id(在dba_free_space表中可檢視),修改大小為11m
alter database datafile 7 resize 11m;
// 刪除表空間(cascade constraint可選擇寫或者不寫,刪除約束)
drop tablespace tbs_01 including contents and datafiles cascade constraint;
//建立表table1
create table table1
(name varchar2(10
),class
varchar2(10
),score number)
;
// 修改表名為table_1
alter table table1 rename to table_1;
// 修改欄位名
alter table table_1 rename column name to ename;
// 修改字段長度
alter table table_1 modify ename varchar2(15
);
// 新增列注釋
comment on column table_1.name is'學生姓名'
;
// 新增表注釋
comment on table table_1 is'學生資訊'
;
// 修改列注釋
comment on column table_1.ename is '學生的姓名'
;
// 資料插入多行
insert into table_1
(ename,
class
,score)
values
('張三'
,'語文',60
);insert into table_1
(ename,
class
,score
)values
('李四'
,'語文',61
);insert into table_1
(ename,
class
,score
)values
('王五'
,'語文',62
);insert into table_1
(ename,
class
,score
)values
('張三'
,'數學',70
);insert into table_1
(ename,
class
,score
)values
('李四'
,'數學',70
);insert into table_1
(ename,
class
,score
)values
('王五'
,'數學',70
);insert into table_1
(ename,
class
,score
)values
('張三'
,'英語',80
);insert into table_1
(ename,
class
,score
)values
('李四'
,'英語',81
);insert into table_1
(ename,
class
,score
)values
('王五'
,'英語',82
);//如果是插入所有字段可以省區=去括號內容
insert into table_1 values
('王五'
,'英語',82
);
// 刪除表結構和內容
drop table table_1;
// 新增列
alter table table_1 add xueqi varchar
(100
);
// 更新一列的值,在實際工作中儘量減少使用。
update table_1 set table_1.xueqi=
'第一學期'
;//高階替換
update table_1 set table_1.xueqi=
replace
(table_1.xueqi,
'一',
'1')
;
Oracle常用知識點
oracle的預設賬號及密碼有以下三種 1.使用者名稱 sys密碼 change on install 2.使用者名稱 system密碼 manager 3.使用者名稱 scott密碼 tiger 注意登陸模式不是normal select 分組的列,sum 要求和的列 from 表 group b...
oracle知識點總結
1.oracle 例項是記憶體結構和後台程序的集合2 oracle 的記憶體結構包含以下兩個記憶體區 系統全域性區 sga 和程式全域性區 pga 3.oracle 伺服器由資料庫和 例項組成 oracle 例項由系統全域性區和用於管理資料庫的後台程序組成 oracle 中用於訪問資料庫的主要查詢工...
知識點總結2
當列表增加或刪除元素時列表物件自動進行記憶體的擴充套件或收縮 列表物件常用方法 extend iterable 將可迭代物件iterable中所有元素新增至列表尾部 insert index,x 在列表指定位置index處新增元素x remove x 在列表中刪除首次出現的指定元素 pop inde...