oracle 語句建立資料庫
阿新 • • 發佈:2019-01-07
1.建立資料表空間
create tablespace SOA
logging datafile ‘D:\app\oradata\ORCL\SOA.dbf’
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
- 建立資料表空間soa
- 設定日誌功能存放地址
- 設定表空間大小32m
- 設定表空間為自動擴充套件
- 設定下次擴充套件大小及最大容量
- 範圍為管理當地
//建立臨時表空間
create temporary tablespace SOA_temp
2.建立使用者
– - - -建立 使用者new_user,密碼root,預設表空間soa- - - -
create user new_user identified by root
default tablespace soa
- - -或者設定為臨時表空間- - -
temporary tablespace lins
3.給使用者授權
登入擁有dba許可權使用者sys
- - - - 給使用者賦予普通操作的許可權- - - - - -
grant connect,resource to username;
4.登入新使用者匯入資料庫 .dmp檔案
- - - - 檢視當前庫的版本號
select * from v$version
- - - - 檢視當前庫的字符集
SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = ‘NLS_CHARACTERSET’;
(NLS_RDBMS_VERSION)為版本號
- - - - 檢視當前庫的所有使用者
select * from user$
- - - - 查看錶空間及大小
SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;
- - - - 檢視當前使用者的預設表空間
select username,default_tablespace from user_users;
- - - - 檢視當前使用者的操作許可權
select * from user_role_privs
- - - - 檢視當前使用者下的所有表
select * from user_tables;
- - - - 修改表空間大小
alter database datafile ’ D:\app\oradata\ORCL\SOA.dbf’
resize 500m;
- - - - 設定資料庫自動增長
alter database datafile ’ D:\app\oradata\ORCL\SOA.dbf’
autoextend on;
- - - - 刪除臨時表空間SOA
//登陸dba許可權的sys使用者執行
drop tablespace SOA including contents and datafiles;
- - - - 刪除使用者new_user 及使用者所有的物件
//登陸dba許可權的sys使用者執行
drop user new_user cascade;
alter user rdzx identified by dreamsoft;
- - - - 檢視修改資料庫遊標大小
select count(*) from v$open_cursor;
alter system set open_cursors=1000 scope=both;
- - - - 修改使用者密碼
重置使用者密碼。命令為:alter user username identified by password;其中username為使用者名稱,password為新密碼。
- - - - 解鎖使用者
在oracle中,連續十次嘗試登陸不成功,那麼此賬戶將會被鎖定(lock)。當使用被鎖定的賬戶登入時,系統會報錯:ORA-28000: the account is locked。
使用命令解鎖使用者。命令為:alter user username account unlock;其中username為被鎖定的使用者名稱。