1.連接數據庫
普通用戶連接數據庫:
conn scott/tiger –(默認的用戶名/密碼)、conn 即”connection”連接數據庫的意思
超級管理員連接:
Conn sys/sys as sysdba–oracle數據庫不區分大小寫
2.sql文件
保存sql文件
save c:/test.txt
編輯sql語句,用記事本編輯
ed c:/1.txt –編輯 SQL 語句
ed –直接打開上一次緩存sql語句
描述數據表的結構
desc employee; –打開employee員工表的結構
spool 錄屏
spool 存放位置(d:/基本查詢.txt)
spool off – 結束錄屏
3.服務器
打開服務器
net start oracleservicebinbo
打開監聽器
lsnrctl start
關閉服務器
net stop oracleservicebinbo
關閉監聽器
lsnrctl stop
4.用戶操作
查看當前用戶的角色
SQL>select * from user_role_privs;
查看當前用戶的系統權限和表級權限
SQL>select * from user_sys_privs;SQL>select * from user_tab_privs;
查看當前用戶的缺省表空間
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 密碼;
創建表空間的數據文件
sql>create tablespace test datafile ‘d:/oracle/binbo.dbf' size 10m;
創建用戶
sql>create user 用戶名 identified by 用戶名;
查看用戶
sql>show user
檢查語句是否有錯
show error
鎖定用戶
sql>alter user 用戶名 account lock
解除用戶
sql>alter user 用戶名 account unlock
刪除用戶
sql>drop user zl;
給用戶創建表權限
sql>grant create table to 用戶名;
授管理員權限
sql>grant dba to 用戶名;
給用戶登錄權限
sql>grant connect to 用戶名
給用戶無限表空間權限
sql>grant unlinmited tablespace to 用戶名;
收回權限
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;
查看某表的創建時間
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');
查看表結構
desc 表名;
查看放在ORACLE的內存區里的表
SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;
再添加一個表空間的數據文件
sql>alter tablespace test add datafile ‘d:/oracle/test1.dbf' size 10m;
6.事務(TC事務控制語言)
COMMIT - 提交并結束事務處理
ROLLBACK - 撤銷事務中已完成的工作
SAVEPOINT – 標記事務中可以回滾的點
總結
以上所述是小編給大家介紹的常用的Oracle doc命令(收藏),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VeVb武林網網站的支持!
新聞熱點
疑難解答