sqlplus常用命令:
1、conn[ect]? ? 連接命令
? ? 用法:conn username/password [as sysdba]
? ? 當(dāng)連接sys用戶時,conn username/password as sysdba(建議不要以sys用戶的身份登錄)
2、disconn[ect]/disc[onnect]? ? 退出當(dāng)前用戶命令
3、password/passw? ? 修改密碼
4、show user? ? 顯示當(dāng)前用戶名
5、clear screen/scr? ? 清除屏幕
6、exit? ? 退出命令? ? 該命令會斷開與Oracle的連接,并關(guān)閉sqlplus窗口。
7、commit; 提交命令? ? 操作結(jié)束后要進(jìn)行提交操作
sqlplus的交互命令:
1、edit
? ? 說明:可以編輯指定的sql腳本
2、spool? ? /? ? spool off
? ? 說明:該命令可以將sqlplus屏幕上的內(nèi)容輸入到指定的.sql文件中(日志)
? ? spool xxxxx.sql
? ? 要往xxxxx.sql里面輸入的東西
? ? spool off
3、show linesize? ? /? ? set linesize 字符大小
? ? 說明:每行顯示的長度(默認(rèn)是80個字符)? ? /? ? 設(shè)置每行的長度
4、show pagesize? ? /? ? set pagesize
? ? 說明:每一頁顯示的行數(shù)(默認(rèn)是14行)? ? /? ? 設(shè)置每頁的行數(shù)
Oracle基本操作
------Oracle用戶的管理
? ? 1、創(chuàng)建用戶
? ? create user [username] identified by [password];
? ? 創(chuàng)建用戶后,用戶沒有任何權(quán)限
? ? 2、刪除用戶
? ? drop user [username]
角色? ? 權(quán)限
? ? 角色:擁有N個權(quán)限的集合。
? ? 角色分為:預(yù)定義角色,自定義角色(根據(jù)用戶的需求添加權(quán)限到某個角色)。
用戶管理的綜合案例:
? ? 概述:創(chuàng)建出來的briup的用戶是沒有任何權(quán)限的,連最基本的登錄數(shù)據(jù)庫的權(quán)限都沒有,需要為它指定相應(yīng)的權(quán)限。
? ? 授予權(quán)限:grant
? ? ? ? grant 具體權(quán)限 to username
? ? ? ? 例如:grant connect to?username ????將connect角色(角色中包含若干權(quán)限)賦予給username
? ? 回收權(quán)限:revoke
? ? ? ? revoke 具體權(quán)限 from username
? ? ? ? 例如:revoke connect to username? ? ?將connect角色(角色中包含若干權(quán)限)回收
創(chuàng)建表格:create table table_name(括號中為表中的字段);
create table 表名 (
字段名1 數(shù)據(jù)類型(長度) ,字段名2 數(shù)據(jù)類型,字段名3 數(shù)據(jù)類型,......
)
例如:create table student_table(student_no number(5),student_name varchar2(10),student_sex varchar2(2));