溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Oracle中常用的doc命令有哪些

發(fā)布時間:2021-07-28 14:00:24 來源:億速云 閱讀:77 作者:小新 欄目:數(shù)據(jù)庫

這篇文章將為大家詳細(xì)講解有關(guān)Oracle中常用的doc命令有哪些,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

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 sysdba
sys
tsinghua
sqlplus “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_objects
where 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_segments
where 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ù)中可以回滾的點

關(guān)于“Oracle中常用的doc命令有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI