oracle 数据库,用户管理以及表空间等相关基础操作
生活随笔
收集整理的這篇文章主要介紹了
oracle 数据库,用户管理以及表空间等相关基础操作
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
開啟超級管理員模式
sqlplus "/as sysdba" 修改BI賬戶密碼為721521
alter user BI identified by 721521; #修改時間格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
#查詢被封的賬戶和被封時間
select username,lock_date from dba_users;
#解鎖賬號
alter user BI account unlock;
#解鎖賬號和同時取消密碼過期 當前ORACLE用戶的狀態(tài)可查看視圖DBA_USERS;一般情況下在使用的正常用戶均處于OPEN狀態(tài)。
select username,account_status from dba_users; 五種基本狀態(tài)可分為三類:1.正常狀態(tài);2.鎖定狀態(tài);3.密碼過期狀態(tài)。 1、OPEN狀態(tài)表示用戶處于正常狀態(tài)。
2、LOCKED和LOCKED(TIMED)表示用戶被鎖定狀態(tài)。
show all 查看系統(tǒng)所有變量值。
show user 顯示當前連接用戶
show error 顯示錯誤
desc 表名 顯示表結(jié)構(gòu)。
/*?? */ 多行注釋
--單行注釋
表空間: 數(shù)據(jù)庫中最大的邏輯單位,每一個數(shù)據(jù)庫至少有一個表空間。
三種類型:
?永久性表空間:存儲表,視圖,過程和索引等數(shù)據(jù)。
?臨時表空間:保存系統(tǒng)中短期活動的數(shù)據(jù)。
?撤銷表空間:回復(fù)回退未提交的事務(wù)數(shù)據(jù)。
?
表空間操作:
?create tablespace 表空間名
??datafile "數(shù)據(jù)文件路徑" size 大小?? --單位 K / M
??[autoextend no] [next 大小]
??[maxsize 大小];
?
?舉個栗子:
??create tablespace test_ts
???datafile 'd:\oracle_data\test.dbf' size 10M
???autoextend no; 查詢表空間:--管理員
select file_name, tablespace,bytes,autoextensible from dba_data_files where tablespace_name = 'test_ts';
?栗子
?--修改表空間
?alter tablespace 表空間名
??add datafile "數(shù)據(jù)文件路徑" size 大小
??[autoextend no] [next 大小]
??[maxsize 大小]; 刪除表空間:
?drop tablespace 表空間名; --之刪除表空間
?drop tablespace 表空間名 including contents and datafiles;? --刪除表空間以及數(shù)據(jù)文件。
?
數(shù)據(jù)庫用戶系統(tǒng)
?常見用戶:
??sys 超級用戶
??sysdba :超級管理員
??system 默認系統(tǒng)管理員
??scott 示范用戶
?
?
?查詢系統(tǒng)用戶:
??select * from all_users;
??select * from dba_users; --更詳細的用戶信息
??
??alter user hr account unlock? 解鎖hr用戶
??
??
?創(chuàng)建用戶:
??create user 用戶名 identified by 密碼
???default tablespace 表空間;
??
??栗子:
??create user test identified by 123456
???default tablespace test_ts
???temporary tablespace temp; --設(shè)置了臨時表空間。
???
?修改密碼:
??alter user 用戶名 identified by 密碼
??栗子:
??alter user test identified by 654321;
??
?刪除用戶:
??drop user 用戶名 cascade;
sqlplus "/as sysdba" 修改BI賬戶密碼為721521
alter user BI identified by 721521; #修改時間格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
#查詢被封的賬戶和被封時間
select username,lock_date from dba_users;
#解鎖賬號
alter user BI account unlock;
#解鎖賬號和同時取消密碼過期 當前ORACLE用戶的狀態(tài)可查看視圖DBA_USERS;一般情況下在使用的正常用戶均處于OPEN狀態(tài)。
select username,account_status from dba_users; 五種基本狀態(tài)可分為三類:1.正常狀態(tài);2.鎖定狀態(tài);3.密碼過期狀態(tài)。 1、OPEN狀態(tài)表示用戶處于正常狀態(tài)。
2、LOCKED和LOCKED(TIMED)表示用戶被鎖定狀態(tài)。
show all 查看系統(tǒng)所有變量值。
show user 顯示當前連接用戶
show error 顯示錯誤
desc 表名 顯示表結(jié)構(gòu)。
/*?? */ 多行注釋
--單行注釋
表空間: 數(shù)據(jù)庫中最大的邏輯單位,每一個數(shù)據(jù)庫至少有一個表空間。
三種類型:
?永久性表空間:存儲表,視圖,過程和索引等數(shù)據(jù)。
?臨時表空間:保存系統(tǒng)中短期活動的數(shù)據(jù)。
?撤銷表空間:回復(fù)回退未提交的事務(wù)數(shù)據(jù)。
?
表空間操作:
?create tablespace 表空間名
??datafile "數(shù)據(jù)文件路徑" size 大小?? --單位 K / M
??[autoextend no] [next 大小]
??[maxsize 大小];
?
?舉個栗子:
??create tablespace test_ts
???datafile 'd:\oracle_data\test.dbf' size 10M
???autoextend no; 查詢表空間:--管理員
select file_name, tablespace,bytes,autoextensible from dba_data_files where tablespace_name = 'test_ts';
?栗子
?--修改表空間
?alter tablespace 表空間名
??add datafile "數(shù)據(jù)文件路徑" size 大小
??[autoextend no] [next 大小]
??[maxsize 大小]; 刪除表空間:
?drop tablespace 表空間名; --之刪除表空間
?drop tablespace 表空間名 including contents and datafiles;? --刪除表空間以及數(shù)據(jù)文件。
?
數(shù)據(jù)庫用戶系統(tǒng)
?常見用戶:
??sys 超級用戶
??sysdba :超級管理員
??system 默認系統(tǒng)管理員
??scott 示范用戶
?
?
?查詢系統(tǒng)用戶:
??select * from all_users;
??select * from dba_users; --更詳細的用戶信息
??
??alter user hr account unlock? 解鎖hr用戶
??
??
?創(chuàng)建用戶:
??create user 用戶名 identified by 密碼
???default tablespace 表空間;
??
??栗子:
??create user test identified by 123456
???default tablespace test_ts
???temporary tablespace temp; --設(shè)置了臨時表空間。
???
?修改密碼:
??alter user 用戶名 identified by 密碼
??栗子:
??alter user test identified by 654321;
??
?刪除用戶:
??drop user 用戶名 cascade;
轉(zhuǎn)載于:https://www.cnblogs.com/gaozd/p/9394894.html
總結(jié)
以上是生活随笔為你收集整理的oracle 数据库,用户管理以及表空间等相关基础操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微服务 第六章 springboot 通
- 下一篇: linux(CentOs6)下jdk安装