温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle菜鸟学习之 Oracle基础命令

发布时间:2020-07-11 22:43:21 来源:网络 阅读:443 作者:运维少年 栏目:关系型数据库

首发:http://www.arppinging.com/wordpress/?p=93

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> 
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI