整理匯總Oracle常用命令 方便你我他建站知識
導讀:1建站知識想統一整理Oracle中常用的命令語句,以后遇到,會不斷更新此博客中。為了以后方便查詢,因此整理此博客中網站建設seo網站優化軟件。
起因
在做Hibernate批量插入時,出現這個錯誤org.hibernate.QueryTimeoutException:
錯誤原因是表空間的容量不足,需要加大空間容量;那首先想到的是應該查詢其容量,所以應該想辦法查詢其容量以及增大其容量。
因此
想統一整理Oracle中常用的命令語句,以后遇到,會不斷更新此博客中。為了以后方便查詢,因此整理此博客中。
Oracle中常用的命令語句如下:
1.創建用戶
create user 用戶名 identified by 密碼
注意:用戶名和密碼最好是英文
如:create user sms identified by sms;
2.創建表空間
create tablespace 表空間名 datafile '存放路徑' size 大小
如:create tablespace ts_sms datafile 'F:\quanxianguanliruanjian\oracle\tablespace\sms.dbf' size 100m;
3.把表空間賦值給剛創建的用戶
alter user 用戶 default tablespace 表空間
如:alter user sms default tablespace ts_sms;
4.給用戶賦權
grant create sesseo網站優化sion,create view,create table,unlimited tablespace to 用戶
如:grant create session,create view,create table,unlimited tablespace to sms;
或者直接把DBA的權限全部賦值給用戶,這樣用戶就有了創建序列等權限
grant dba to user; 如:grant dba to sms;
5.切換到新建的用戶登錄
conn 用戶/密碼
如:conn sms/sms;
其中1——5是新建用戶,到導入sql之間的過程。
6.刪除用戶
drop user 用戶名
如:drop user sms;
7.修改用戶的密碼
alter user 用戶名 identified by 新密碼
如:alter user test identified by test;
8.查看所有的用戶
select * from dba_users; 或者 select * from all_users; 或者 select * from user_users;
其中select * from user_users;只能看當前的用戶
9.查看當前用戶或DBA角色的權限
select * from user_sys_privs; select * from dba_sys_privs;
10.查看表空間的容量
SQL> selecttablespace_name "表空間" , bytes/1024/1024 "總容量MB" fromdba_data_files;
結果如下:
11.查看表空間的使用情況,剩余情況
SQL> selecta.tablespace_name as 表空間, a.bytes/1024/1024 as 總容量MB ,(a.bytes-b.bytes)/1024/1024 "使用容量MB",b.bytes/1024/1024 "剩余容量MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "使用百分比" from (select tablespace_name,sum(bytes) bytes fromdba_data_files group by tablespace_name) a,(select tablespace_網站優化seo培訓name,sum(bytes)bytes,max(bytes) largest from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_nameorder by ((a.bytes-b.bytes)/a.bytes) desc;
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-23 ,文章整理匯總Oracle常用命令 方便你我他建站知識主要講述你我他,方便,整理匯總Oracle常用命令 方便你我他網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_5731.html