Oracle菜鳥學習之 Oracle基礎命令


Oracle菜鳥學習之 Oracle基礎命令

1.connect和show user

連接用戶和查看當前用戶

SQL> show user;
USER is "SCOTT"
SQL> conn /as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> 

2.clear screen

清除屏幕輸出

3.spool

記錄輸出內容到文本

# 開啟記錄
SQL> spool /tmp/sql.txt
SQL> select * from student;

       SNO SNAME                          BIRTHDAY
---------- ------------------------------ -------------------
         1 A                              0011-01-01 00:00:00
         2 B                              2011-01-01 00:00:00
         3                                1981-02-23 00:00:00
         4 D

SQL> spool off
#關閉記錄
# 查看文本是否有記錄內容
[root@localhost tmp]# cat /tmp/sql.txt 
SQL> select * from student;

       SNO SNAME                          BIRTHDAY                              
---------- ------------------------------ -------------------                   
         1 A                              0011-01-01 00:00:00                   
         2 B                              2011-01-01 00:00:00                   
         3                                1981-02-23 00:00:00                   
         4 D                                                                    

SQL> spool off
[root@localhost tmp]# 

4.set time on

將時間信息打印在提示符的左邊

#開啟時間顯示
SQL> set time on
16:02:39 SQL> 
16:02:41 SQL> set time off
# 關閉時間顯示
SQL> 

5.host

host可以執行linux或者windows的命令

SQL> host ls -l
total 40
-rw-r--r--. 1 oracle oinstall   20 Oct  3 12:59 afiedt.buf
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Desktop
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Documents
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Downloads
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Music
drwxr-x---. 3 oracle oinstall 4096 Oct  2 11:28 oradiag_oracle
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Pictures
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Public
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Templates
drwxr-xr-x. 2 oracle oinstall 4096 Oct  2 10:54 Videos

SQL> 

6.@

@在oracle中可以用來執行腳本中的內容

# 查看腳本信息

[root@localhost tmp]# cat test.sql 
select * from student;
show user;
root@localhost tmp]# 

# 執行腳本

SQL> @/tmp/test.sql

       SNO SNAME                          BIRTHDAY
---------- ------------------------------ -------------------
         1 A                              0011-01-01 00:00:00
         2 B                              2011-01-01 00:00:00
         3                                1981-02-23 00:00:00
         4 D

USER is "SCOTT"
SQL> 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM