linuxcoracle
㈠ linux C/C++用什麼連接oracle資料庫啊解決辦法
在Windows的控制面板中,查找ODBC數據源,配置一個能夠連接Oracle的數據源,並測試能夠成功連接。然後在VS中連接這個數據源即可。
㈡ 怎麼在linux環境下通過c/c++語言連接oracle資料庫
推薦你使用pc語言,用這個編寫代碼很容易對資料庫oracle進行操作.各種操作都非常簡單.
例如:
EXEC sql CONNECT :UserName IDENTIFIED BY :PassWord using :ServerName;
這樣一個簡單語句就可以實現連接資料庫.
EXEC SQL CALL insert_data_sms(:spnumber,:usernumber,:content,:flag,:priority,:spnode,:sequenid_sp,:iresult);
EXEC SQL COMMIT;/*提交事務*/
可調用存儲過程.
你可以找找這方便的書看看
㈢ linux中oracle服務啟動都有哪些方法
手動啟動:
用 oracle用戶登錄(或su - oracle)
lsnrctl start
sqlplus / as sysdba
startup
exit
自動啟動,要編寫一個啟動腳本,用root用戶拷到/etc/init.d下,取名叫oracle
然後, chkconfig oracle on,即可加入服務列表
/etc/init.d/oracle start #啟動
/etc/init.d/oracle stop #停止
腳本的示例(裡面的變數要按實際情況修改):
#!/bin/bash
#
# chkconfig: 345 99 01
# description: This is a program that is responsible for taking care of
# configuring the Oracle Database 11g Stardard/Enterprise Edition and its associated
# services.
#
# Source fuction library
if [ -f /lib/lsb/init-functions ]
then
. /lib/lsb/init-functions
elif [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
fi
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/sbin:/etc
export PATH ;;
esac
# Save LD_LIBRARY_PATH
SAVE_LLP=$LD_LIBRARY_PATH
RETVAL=0
ORACLE_OWNER=oracle
ORACLE_OWNER_HOME=/opt/oracle
ORACLE_BASE=$ORACLE_OWNER_HOME/app/oracle
ORACLE_HOME=$ORACLE_BASE/proct/11.2.0/dbhome_1
ORACLE_SID=orcl
ORACLE_UNQNAME=$ORACLE_SID
LSNR=$ORACLE_HOME/bin/lsnrctl
SQLPLUS=$ORACLE_HOME/bin/sqlplus
STARTDB_SQL=$(mktemp /tmp/start.XXXXXX)
echo -e "startup;\nquit;\n" > $STRTDB_SQL
STOPDB_SQL=$(mktemp /tmp/stop.XXXXXX)
echo -e "shutdown immediate;\nquit;\n" > $STOPDB_SQL
SU=/bin/su
export ORACLE_HOME
export ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
LOG="$ORACLE_HOME_LISTNER/listener.log"
export LC_ALL=C
if [ $(id -u) != "0" ]
then
echo "You must be root to run the configure script. Login as root and then run the
configure script."
exit 1
fi
if [ -f /etc/redhat-release ]
then
. /etc/init.d/functions
init_status()
{
return 0
}
exit_status()
{
exit $?
}
success_status()
{
success
echo
}
failure_status()
{
failure $?
echo
}
elif [ -f /etc/SuSE-release ]
then
. /etc/rc.status
init_status()
{
rc_reset
}
success_status()
{
echo "OK"
return 0
}
failure_status()
{
echo "Failed"
return 1
}
exit_status()
{
exit $?
}
else
if [ -d /etc/default ]
then
CONFIGURATION="/etc/default/$CONFIG_NAME"
fi
init_status()
{
return 0
}
success_status()
{
echo "OK"
return 0
}
failure_status()
{
echo "Failed"
return 0
}
exit_status()
{
exit $?
}
fi
init_status
start() {
status=`ps -ef | grep tns | grep oracle`
if [ "$status" == "" ]
then
if [ -f $ORACLE_HOME/bin/tnslsnr ]
then
echo "Starting Oracle Net Listener."
$SU -s /bin/bash $ORACLE_OWNER -c "$LSNR start" # > /dev/null 2>&1
fi
fi
echo "Starting Oracle Database 11g Instance."
$SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog @${STARTDB_SQL}" # > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo
else
echo Failed to start Oracle Net Listener using $ORACLE_HOME/bin/tnslsnr\
and Oracle Database using $ORACLE_HOME/bin/sqlplus.
RETVAL=1
return $RETVAL
fi
}
startconsole() {
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole &" # > /dev/null 2>&1
RETVAL=$?
return $RETVAL
}
stop() {
# Stop Oracle 11g Database and Listener
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole &" # > /dev/null 2>&1
echo Shutting down Oracle Database 11g Instance.
$SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog @${STOPDB_SQL}" # > /dev/null 2>&1
echo Stopping Oracle Net Listener.
$SU -s /bin/bash $ORACLE_OWNER -c "$LSNR stop" # > /dev/null 2>&1
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$LSNR
then
return $RETVAL
fi
}
stopconsole() {
# Stop Oracle 11g Database and Listener
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole &" # > /dev/null 2>&1
RETVAL=$?
return $RETVAL
}
# See how we were called
case "$1" in
start)
start
;;
startconsole)
startconsole
;;
stop)
stop
;;
stopconsole)
stopconsole
;;
restart|reload|force-reload)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac
㈣ linux怎麼登陸oracle資料庫
×
loading..
資訊
安全
論壇
下載
讀書
程序開發
資料庫
系統
網路
電子書
微信學院
站長學院
QQ
手機軟體
考試
頻道欄目
SQL Server|
MySQL|
Oracle|
DB2|
Sybase|
其他綜合|
SQL教程|
登錄注冊
首頁 > 資料庫 > Oracle > 正文
連接Linux伺服器操作Oracle資料庫
2013-03-20 10:48:47
0個評論
收藏
我要投稿
連接Linux伺服器操作Oracle資料庫
由於項目已經上線,現場的資料庫伺服器不允許直接用Oracle的客戶端plsqldev.exe來連接,只能通過Linux伺服器的命令來操作。 以下是用SecureCRT 5.1客戶端連接Linux伺服器來操作Oracle資料庫:
1.連接到Linux伺服器(輸入伺服器的ip地址)
ssh 10.199.94.227
連接成功後會提示輸入密碼,輸入成功會提示。
2.切換到操作Oracle資料庫
su - oracle
切換成功會提示相關資料庫的實例。例如:oracle@linux-cg01:~>
3.切換到sqlplus操作
sqlplus /nolog
切換成功會提示相關的提示:例如:
SQL*Plus: Release 11.2.0.2.0 Proction on Thu Jan 19 11:19:48 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
4.輸入資料庫的用戶名和密碼
conn personal/personal
5.會提示Connected.(連接成功),顯示 SQL> :
6.以下是相關的SQL語句操作:
(1) 查詢的語句後面要一定要加 ; ,否則不能執行查詢,相當於plsqldev.exe工具的命令窗口的操作
select *from newuseraccount (記得查詢的時候一定要加;)
select email,password from userreg where accountstype=1 and userstate=1;
(2)插入或更新的語句記得還要加提交語句,才能提交事務。相當於plsqldev.exe工具的命令窗口的操作。
update newuseraccount set address='address ' where userid=638 ;
commit ;
㈤ linux 下的oracle怎麼啟動
su - oracle
lsnrctl start
sqlplus / as sysdba
startup
詳細步驟如下:
1.進入到sqlplus啟動實例
[oracle@redhat~]$su-oracle--「切換到oracle用戶」
Password:
[oracle@redhat~]$lsnrctlstart--「打開監聽」
LSNRCTLforLinux:Version10.2.0.1.0-Proctionon14-OCT-200919:06:40
Copyright(c)1991,2005,Oracle.Allrightsreserved.
Starting/home/oracle/proct/10g/bin/tnslsnr:pleasewait...
TNSLSNRforLinux:Version10.2.0.1.0-Proction
Systemparameterfileis/home/oracle/proct/10g/network/admin/listener.ora
Logmessageswrittento/home/oracle/proct/10g/network/log/listener.log
Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
STATUSoftheLISTENER
------------------------
AliasLISTENER
VersionTNSLSNRforLinux:Version10.2.0.1.0-Proction
StartDate14-OCT-200919:06:40
Uptime0days0hr.0min.0sec
TraceLeveloff
SecurityON:LocalOSAuthentication
SNMPOFF
ListenerParameterFile/home/oracle/proct/10g/network/admin/listener.ora
ListenerLogFile/home/oracle/proct/10g/network/log/listener.log
ListeningEndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
ServicesSummary...
Service"PLSExtProc"has1instance(s).
Instance"PLSExtProc",statusUNKNOWN,has1handler(s)forthisservice...
[oracle@redhat~]$sqlplus/nolog--「進入到sqlplus」
SQL*Plus:Release10.2.0.1.0-ProctiononWedOct1419:06:452009
Copyright(c)1982,2005,Oracle.Allrightsreserved.
SQL>conn/assysdba--「連接到sysdba」
Connectedtoanidleinstance.
SQL>startup--「啟動資料庫實例」
ORACLEinstancestarted.
FixedSize1218968bytes
VariableSize88082024bytes
DatabaseBuffers188743680bytes
RedoBuffers7168000bytes
Databasemounted.
Databaseopened.
SQL>shutdownimmediate--「關閉資料庫實例」
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>exit
.2.0.1.0-Proction
WiththePartitioning,OLAPandDataMiningoptions
[oracle@redhat~]$lsnrctlstop--「關閉監聽」
LSNRCTLforLinux:Version10.2.0.1.0-Proctionon14-OCT-200919:08:06
Copyright(c)1991,2005,Oracle.Allrightsreserved.
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
㈥ 我想在linux下用C語言連接遠程oracle,可以不裝客戶端而用代碼實現連接並操作嗎如果可以,怎麼連
必須使用orcale資料庫提供的客戶端開發庫中的函數來和oracle資料庫伺服器來進行通訊。
㈦ 講解linux環境下Oracle的自動啟動與停止
修改Oracle系統配置文件/etc/oratab
/etc/oratab 格式為 SID:ORACLE_HOME:AUTO
把AUTO域設置為Y(大寫) 只有這樣 oracle 自帶的dbstart和dbshut才能夠發揮作用 我的為
ora i:/home/oracle/ora/procts/ :Y
編寫服務腳本
如下
#!/bin/bash
#
#################FUNCTION#############
#
# AutoStart Oracle and listener
# AutoStop Oracle and listener
#
冊運#####################################
#
# Created by ZhouYS
#
case $ in
start)
echo Starting Oracle Databases
echo >> /var/log/oracle
date + %T %a %D : Starting Oracle Databasee as part of system up >> /var/log/oracle
echo >> /var/log/oracle
su oracle c dbstart >> /var/log/oracle
echo Done
echo Starting Oracle Listeners
echo >> /var/log/oracle
date + %T %a %D : Starting Oracle Listeners as part of system up >> /var/log/oracle
echo >> /var/log/oracle
su oracle c lsnrctl start >> /var/log/oracle
echo Done
echo
echo >> /var/log/oracle
date + %T %a %D : Finished >> /var/log/oracle
echo >> /var/log/oracle
touch /var/lock/subsys/oracle
虛姿汪;;
stop)
echo Stoping Oracle Listeners
echo >> /var/log/oracle
date + %T %a %D : Stoping Oracle Listener as part of system down >> /var/log/oracle
echo >> /var/log/oracle
su oracle c lsnrctl stop >> /var/log/oracle
echo Done
rm f /var/lock/subsys/oracle
echo Stoping Oracle Databases
echo >> /var/log/oracle
date + %T %a %D : Stoping Oracle Databases as part of system down >> /var/log/oracle
echo >> /var/log/oracle
su oracle c dbshut >>/var/log/oracle
echo Done
echo
echo >> /var/log/oracle
date + %T %a %D : Finished >> /var/log/oracle
echo >> /var/log/oracle
差仔;;
restart)
$ stop
$ start
;;
*)
echo Usage: oracle {start|stop|restart}
exit
esac
將腳本命名為oracle 保存在/etc/rc d/init d下改變文件屬性 chmod oracle
注意 在windows下編輯此文件時有DOS格式字元導致在linux下不能夠正常運行 建議用gedit 或用 vi編輯
建立服務連接
系統啟動時啟動資料庫 我們需要以下連結∶
$ ln s /init d/oracle /etc/rc d/rc d/S oracle
$ ln s /init d/oracle /etc/rc d/rc d/S oracle
$ ln s /init d/oracle /etc/rc d/rc d/S oracle #rc d unused
要在重新啟動時停止資料庫 我們需要以下連結∶
$ ln s /init d/oracle /etc/rc d/rc d/K oracle # 停止
lishixin/Article/program/Oracle/201311/17142
㈧ linux下怎麼安裝oracle
優酷上有現成的教程,360ito技術論壇上也有,你搜linux下oracle安裝就可以找到