Oracle系列:(4)Oracle預備知識2

來源:互聯網
上載者:User

標籤:oracle



1、普通使用者修改自己的密碼

使用password命令,為scott使用者名稱修改新密碼,以字母開頭,但提倡使用tiger

password舊口令:tiger新口令:abc123再次輸入新口令:abc123


2、退出sqlplus工具

exit


3、查詢目前使用者是誰

show user;


4、查詢scott使用者下的所有對象

使用tab表,tab表每個使用者都有

select * from tab;


5、設定顯示的列寬

(1)設定顯示的列寬(字元型varchar2、日期型date),10個寬度位,a表示字元型,大小寫均可

column ename format a12;

column hiredate format a10;


(2)設定顯示的列寬(數值型number),9表示數字型,一個9表示一個數字位,四個9表示四個數字位,只能用9

column empno format 9999;

column mgr format 9999;

column sal format 9999;

column comm format 9999;

column deptno format 9999;


650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/86/EE/wKiom1fO8KnTjVfIAAAQ1zq2vU8645.png" title="001.PNG" alt="wKiom1fO8KnTjVfIAAAQ1zq2vU8645.png" />


6、設定一頁顯示80個條記錄的高度

set pagesize 80;


7、使用/杠,執行最近一次的SQL語句

/


8、清屏,屬於SQL*PLUS工具中的命令

host cls;


9、查詢emp表的結構

desc emp;

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M00/86/EE/wKiom1fO8t_i6C5xAAAWJ2nsm5Q612.png" title="003.PNG" alt="wKiom1fO8t_i6C5xAAAWJ2nsm5Q612.png" />


10、根據已有表建立新表

--建立新表new_emp,複製emp表中的結構和資料到new_emp表中(注意:不要省略as)

create table copy_emp as select * from emp;

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/86/EE/wKiom1fO8jOgJ6eLAAAYqh7d13c349.png" title="002.PNG" alt="wKiom1fO8jOgJ6eLAAAYqh7d13c349.png" />


11、將SQL語句輸出到檔案 和 從檔案中讀取SQL

使用spool命令,儲存SQL語句到硬碟檔案e:/oracle-day01.sql,並建立sql檔案

spool e:/oracle-day01.sql;


使用spool off命令,儲存SQL語句到硬碟檔案e:/oracle-day01.sql,並建立sql檔案,結束語句

spool off;

它會將SQL語句和查詢結果都輸出到檔案中


使用@命令,將硬碟檔案e:/crm.sql,讀到orcl執行個體中,並執行檔案中的sql語句

@ e:/crm.sql;


12、注釋

使用--符號,設定單行注釋

--select * from emp;


使用/* */符號,設定多行注釋

/*select*from emp;*/

總結:學過的所有技術中,關於注釋的符號


html <!--...-->
css /*注釋*/
js

// 

/*注釋*/

xml <!--注釋-->
jsp <%--注釋--%>
mysql

-- 

/*注釋*/

參考:http://www.cnblogs.com/end/archive/2011/03/31/2001109.html

oracle

--

/* */

java

//

/* */


Oracle系列:(4)Oracle預備知識2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.