【正文】
OPC學(xué)習(xí)筆記一db基礎(chǔ)知識Linix環(huán)境下$. oraenv/sid(數(shù)據(jù)庫名字) sid=orcl/home(數(shù)據(jù)庫路徑) home=/u01/..../dbsqlplus sys/ ****(任 意) as sysdba(都可以聯(lián)上)[sysdba用戶]connect idle instance(連接到了一個空閑的實例上,服務(wù)沒有開)需要startup啟動默認實例Windows環(huán)境下sql /nolog (不登陸,只連接到軟件)conn / as sysdba(以AS用戶連接到數(shù)據(jù)庫)sqlplus sys/ ****(任 意) as sysdba(都可以聯(lián)上)show user(顯示用戶)sqlplus scott/tiger默認用戶:scott 默認密碼:tigeralter user scott account lock:(用戶名鎖定)alter user scott identified by tiger account unlock:(將用戶scott的密碼改成tiger并解鎖)select * from cat。(顯示表)desc emp (顯示emp表的結(jié)構(gòu))select table_name from user_tables。(顯示表,更通用)SQL 結(jié)構(gòu)select 查詢DML insert update deleteDDL creat alter truncate dropTC 事物控制 mit rollback savepoint字典user_tableOTHERS view index 同義詞 序列詞DCL grant revokeselect * from dept。+ * / ( )別名 連接符 ||edit (編輯)編輯器中注不要加‘;’list (顯示上一次成功運行的命令)alter session set NLS_DATE_LANGUAGE=americandistinct(去重復(fù))找重復(fù)的記錄insert into 表名val ()mit。有條件 〉〈 != 〈〉between and in (A,B,C)like 39。%39。代表多個字符 39。_39。 代表一個字符escape 轉(zhuǎn)移符 like 39。IT~_%39。escape 39。~39。scott維護alter user scott identified by tiger account unlock。RDBMS\ADMIN\二 簡單查詢查詢員工名稱,工號,工資select ename,empno,sal from emp。查詢每個員工工資加500元是多少select ename,sal+500 from emp。查詢加工資后每個員工的年薪select ename,sal+500 from emp。年薪用中文表示列頭/特殊字符用雙引號select ename as 名稱,(sal+500)*12 年薪 from emp。查詢每個人的工資是多少select ename||39。的薪水是39。||(sal+500) from emp。查詢每個人的年薪是多少select ename||39。的年薪是39。||(sal+500)*12 from emp。英文以上問題顯示xxx’s sal is:xxxxselect ename||q39。[39。s sal is :]39。||(sal+500) from emp。select ename||39。39。39。s sal is :39。||(sal+500) from emp。查詢部門編號有哪些(性能考量)呢?select deptno from emp。select distinct deptno from emp。select deptno from dept。三 限制查詢查詢出工資大于1500的員工,準備炒他們魷魚select empno,ename,sal from emp where sal =1500。查詢工資在1688和2888之間的員工信息select empno,ename,sal from emp where sal between 1688 and 2888。會話語言更改,日期顯示問題(中/英)alter session set nls_date_language = 39。american39。 select ename,hiredate from emp。alter session set nls_date_language = 39