欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Oracle基礎(chǔ):程序中調(diào)用sqlplus的方式

 更新時(shí)間:2018年12月27日 09:11:56   作者:liumiaocn  
今天小編就為大家分享一篇關(guān)于Oracle基礎(chǔ):程序中調(diào)用sqlplus的方式,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧

通過sqlplus可以連接數(shù)據(jù)庫根據(jù)用戶權(quán)限進(jìn)行數(shù)據(jù)或者設(shè)定操作,但是需要交互操作并返回結(jié)果,這篇文章介紹一下如何在程序中使用sqlplus。

環(huán)境準(zhǔn)備

使用Oracle的精簡版創(chuàng)建docker方式的demo環(huán)境,詳細(xì)可參看:

Here Document

因?yàn)閟qlplus是控制臺(tái)的方式與用戶進(jìn)行交互式的輸入/輸出對(duì)應(yīng),而在程序執(zhí)行的過程中顯然是需要預(yù)先定好的輸入,這樣可以考慮使用Here Document,比如希望通過sqlplus來確認(rèn)數(shù)據(jù)庫版本信息,則可以這樣

# sqlplus system/liumiao123 <<EOF
> select * from v\$version;
> EOF
SQL*Plus: Release 11.2.0.2.0 Production on Sun Oct 21 11:06:42 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> 
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
#

注意:需要注意v$version中的$需要轉(zhuǎn)義

創(chuàng)建table

接下來使用Here Document的方式調(diào)用sqlplus來創(chuàng)建table

# sqlplus system/liumiao123 <<EOF
> create table student (
> stuid number(4),
> stuname varchar2(50),
> primary key (stuid)
> );
> desc student;
> EOF
SQL*Plus: Release 11.2.0.2.0 Production on Sun Oct 21 11:11:52 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>  2  3  4  5 
Table created.
SQL> Name    Null?  Type
 ----------------------------------------- -------- ----------------------------
 STUID    NOT NULL NUMBER(4)
 STUNAME     VARCHAR2(50)
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
#

小結(jié)

sqlplus結(jié)合Here Document即可實(shí)現(xiàn)在程序中調(diào)用sqlplus。

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

相關(guān)文章

最新評(píng)論