Oracle 系統(tǒng)命令
1、連接數(shù)據(jù)庫
Sql代碼
SQL> conn 用戶名/密碼@網(wǎng)絡(luò)服務(wù)名SID [as sysdba/sysoper] 當(dāng)用特權(quán)用戶身份連接的時,必須帶上as sysdba或者as sysoper
SQL> conn 用戶名/密碼@網(wǎng)絡(luò)服務(wù)名SID [as sysdba/sysoper] 當(dāng)用特權(quán)用戶身份連接的時,必須帶上as sysdba或者as sysoper
2、顯示當(dāng)前用戶
Sql代碼
SQL> show user;
SQL> show user;
3、修改密碼
Sql代碼
管理員自己修改密碼: passw 管理員修改其他用戶密碼: passw 用戶名
管理員自己修改密碼: passw 管理員修改其他用戶密碼: passw 用戶名
4、退出
Sql代碼
SQL> exit;
SQL> exit;
5、運行sql腳本
Sql代碼
SQL> start c:\test.sql; 或者SQL> @ c:\test.sql;
SQL> start c:\test.sql;或者SQL> @ c:\test.sql;
6、編輯sql腳本
Sql代碼
SQL> edit c:\test.sql;
SQL> edit c:\test.sql;
7、將指定查詢內(nèi)容輸出到指定文件中去
把emp表中的數(shù)據(jù)放在d:\test.sql這個文件中
Sql代碼
SQL> spool d:\test.sql;
SQL> select * from emp;
SQL> sppool off;
SQL> spool d:\test.sql;
SQL> select * from emp;
SQL> sppool off;
Oracle 用戶管理
切換用戶
Sql代碼
SQL> conn system/manager
SQL> conn system/manager
創(chuàng)建用戶
Sql代碼
SQL> create user 用戶名 identified by 密碼
SQL> create user 用戶名 identified by 密碼
修改別人密碼
Sql代碼
SQL> password 用戶名
SQL> alter user 用戶名 identified by 新密碼
SQL> password 用戶名
SQL> alter user 用戶名 identified by 新密碼
刪除用戶(自己刪除自己不可以)
如果要刪除用戶,并且同時要刪除用戶所創(chuàng)建在表,那么就需要在刪除時帶一個參數(shù)cascade;
Sql代碼
SQL> drop user 用戶名 [cascade]
SQL> drop user 用戶名 [cascade]
角色管理權(quán)限
受理連接數(shù)據(jù)庫權(quán)限(connect)給一個用戶
Sql代碼
SQL> grant connect to 用戶名
SQL> grant connect to 用戶名
授權(quán)username查詢emp權(quán)限
Sql代碼
SQL> grant select on emp to username
SQL> grant insert on emp to username
SQL> grant update on emp to username
SQL> grant delete on emp to username
SQL> grant select on emp to username
SQL> grant insert on emp to username
SQL> grant update on emp to username
SQL> grant delete on emp to username
授權(quán)username對emp所有權(quán)限
Sql代碼
SQL> grant all on emp to username
SQL> grant all on emp to username
權(quán)限傳遞
如果是對象權(quán)限,權(quán)限在傳遞就在后面加with grant option
Sql代碼
SQL> grant select on emp to username with grant option
SQL> grant select on emp to username with grant option
如果是系統(tǒng)權(quán)限,權(quán)限在傳遞就在后面加with admin option 這使username可以把select權(quán)限傳遞給其他人
Sql代碼
SQL> grant connect on emp to username with admin option
SQL> grant connect on emp to username with admin option
收回username在我的emp表上在select權(quán)限
Sql代碼
SQL> revoke select on emp from username
SQL> revoke select on emp from username
profile 規(guī)則
賬戶鎖定
指定賬戶登陸最多可以輸入密碼在次數(shù),也可以指定用戶鎖定在時間(天)一般用dba在身份去執(zhí)行該命令
Sql代碼
SQL> create profile lock_account limit failed_login_attempts 3 password_lock_time 2;
lock_account: 名稱隨便取名
3:最多輸入3次密碼
2:鎖定2天
其他的都是關(guān)鍵字
SQL> create profile lock_account limit failed_login_attempts 3 password_lock_time 2;
lock_account:名稱隨便取名
3:最多輸入3次密碼
2:鎖定2天
其他的都是關(guān)鍵字
把鎖lock_account給scott.如果用戶連續(xù)輸入3次錯誤密碼,那么你就被鎖定2天,2天后才能登陸
Sql代碼
SQL> alter user scott profile lock_account;
SQL> alter user scott profile lock_account;
。。。。。。。。待續(xù)