1.連接數(shù)據(jù)庫
普通用戶連接數(shù)據(jù)庫:
conn scott/tiger –(默認(rèn)的用戶名/密碼)、conn 即”connection”連接數(shù)據(jù)庫的意思
超級管理員連接:
Conn sys/sys as sysdba–oracle數(shù)據(jù)庫不區(qū)分大小寫
2.sql文件
保存sql文件
save c:/test.txt
編輯sql語句,用記事本編輯
ed c:/1.txt –編輯 SQL 語句
ed –直接打開上一次緩存sql語句
描述數(shù)據(jù)表的結(jié)構(gòu)
desc employee; –打開employee員工表的結(jié)構(gòu)
spool 錄屏
spool 存放位置(d:/基本查詢.txt)
spool off – 結(jié)束錄屏
3.服務(wù)器
打開服務(wù)器
net start oracleservicebinbo
打開監(jiān)聽器
lsnrctl start
關(guān)閉服務(wù)器
net stop oracleservicebinbo
關(guān)閉監(jiān)聽器
lsnrctl stop
4.用戶操作
查看當(dāng)前用戶的角色
SQL>select * from user_role_privs;
查看當(dāng)前用戶的系統(tǒng)權(quán)限和表級權(quán)限
SQL>select * from user_sys_privs;SQL>select * from user_tab_privs;
查看當(dāng)前用戶的缺省表空間
SQL>select username,default_tablespace from user_users;
換用戶
conn as sysdbasystsinghuasqlplus “sys/tsinghua as sysdba”conn sys/zl as sysdba
更改用戶密碼
sql>alter user 管理員 identified by 密碼;
創(chuàng)建表空間的數(shù)據(jù)文件
sql>create tablespace test datafile ‘d:/oracle/binbo.dbf' size 10m;
創(chuàng)建用戶
sql>create user 用戶名 identified by 用戶名;
查看用戶
sql>show user
檢查語句是否有錯
show error
鎖定用戶
sql>alter user 用戶名 account lock
解除用戶
sql>alter user 用戶名 account unlock
刪除用戶
sql>drop user zl;
給用戶創(chuàng)建表權(quán)限
sql>grant create table to 用戶名;
授管理員權(quán)限
sql>grant dba to 用戶名;
給用戶登錄權(quán)限
sql>grant connect to 用戶名
給用戶無限表空間權(quán)限
sql>grant unlinmited tablespace to 用戶名;
收回權(quán)限
sql>revoke dba from 用戶名;
5.查看表
查看用戶下所有的表
SQL>select * from user_tables;
查看名稱包含log字符的表
SQL>select object_name,object_id from user_objectswhere instr(object_name,'LOG')>0;
查看某表的創(chuàng)建時間
SQL>select object_name,created from user_objects where object_name=upper(‘&table_name');
查看某表的大小
SQL>select sum(bytes)/(1024*1024) as “size(M)” from user_segmentswhere segment_name=upper(‘&table_name');
查看表結(jié)構(gòu)
desc 表名;
查看放在ORACLE的內(nèi)存區(qū)里的表
SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;
再添加一個表空間的數(shù)據(jù)文件
sql>alter tablespace test add datafile ‘d:/oracle/test1.dbf' size 10m;
6.事務(wù)(TC事務(wù)控制語言)
COMMIT - 提交并結(jié)束事務(wù)處理
ROLLBACK - 撤銷事務(wù)中已完成的工作
SAVEPOINT – 標(biāo)記事務(wù)中可以回滾的點(diǎn)
總結(jié)
以上所述是小編給大家介紹的常用的Oracle doc命令(收藏),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對VeVb武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選