溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

cx_Oracle 連接 Oracle

發(fā)布時(shí)間:2020-08-11 08:12:31 來(lái)源:ITPUB博客 閱讀:207 作者:wpgy 欄目:開發(fā)技術(shù)
cx_Oracle has the capability of starting up the database using a privileged connection. This example shows a script that could be run as the ‘oracle’ operating system user who administers a local database installation on Linux. It assumes that the environment variable ORACLE_SID has been set to the SID of the database that should be started:
# the connection must be in PRELIM_AUTH mode to perform startup connection = cx_Oracle.connect("/", mode = cx_Oracle.SYSDBA | cx_Oracle.PRELIM_AUTH) connection.startup()# the following statements must be issued in normal SYSDBA mode connection = cx_Oracle.connect("/", mode = cx_Oracle.SYSDBA, encoding="UTF-8") cursor = connection.cursor() cursor.execute("alter database mount") cursor.execute("alter database open")

Similarly, cx_Oracle has the ability to shutdown the database using a privileged connection. This example also assumes that the environment variable ORACLE_SID has been set:
# need to connect as SYSDBA or SYSOPER connection = cx_Oracle.connect("/", mode = cx_Oracle.SYSDBA)# first shutdown() call must specify the mode, if DBSHUTDOWN_ABORT is used, # there is no need for any of the other steps connection.shutdown(mode = cx_Oracle.DBSHUTDOWN_IMMEDIATE) # now close and dismount the database cursor = connection.cursor() cursor.execute("alter database close normal") cursor.execute("alter database dismount") # perform the final shutdown call connection.shutdown(mode = cx_Oracle.DBSHUTDOWN_FINAL)
向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI