Linux下用OCCI或OCI连接Oracle数据库
首先,去Oracle官网下载C语言的库文件和头文件网址如下,选择对应的Instant Client版本(我下载的都是zip包,没有下载rpm包,rpm
首先,去Oracle官网下载C语言的库文件和头文件网址如下,选择对应的Instant Client版本(我下载的都是zip包,没有下载rpm包,rpm包应该安装的时候就把那些东西配置好了):(个人建议下zip包,,自己打动手玩,能加强理解)
下面是linux i386版本的
Instant Client Package - Basic 里面包含了动态库文件 libclntsh.so.11.1(最新版本可能不一样) 并将其加载到动态库搜索路径中去(具体操作sudo mv *.so /usr/bin)。
*Instant Client Package - SDK 这个则是包含的头文件
*Instant Client Package - SQL*Plus sqlplus这个东西最好还是下一个装上,试验客户端是否配置好,查看sql语句执行结果都需要他。
下面是我下的三个:
instantclient-basic-linux32-11.2.0.2.0.zip
instantclient-sdk-linux32-11.2.0.2.0.zip
instantclient-sqlplus-linux32-11.2.0.2.0.zip
下载文件路径设置:
/home/oracle/lib 存放Basic和sqlplus的各种库文件,因此在/etc/ld.so.conf文件中添加路径/home/oracle/lib ,还有就是在当前文件下为libclntsh.so.11.1库文件建个软连接 ln -s libclntsh.so.11.1 libclntsh.so 让代码连接动态库的时候能找到库文件。(其实里面还有好多.so文件,都是动态库,都要像libclntsh.so.11.1一样放到动态库的时候能找到库文件)
执行ldconfig
/home/oracle/include 存放SDK的头文件。
# tnsnames.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
TEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.8)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
配置好上面这些后,注销用户重新登录,让 ORACLE_HOME环境变量生效,检查方法很简单,分别在终端输入命令:
[@localhost ~]$ echo $ORACLE_HOME
/home/oracle
如果像上面那样有路径输出则说明配置成功了,如果没有输出那重新再编辑一下 ~/.bashrc 看看哪里出了问题吧。
检查完成以后运行sqlplus登录数据库成功!例子如下,运行C程序链接数据库也成功!总算把环境配好了。
其实这时候还出现了问题(估计是我好久没更新,可能是属于个别问题),就是./sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
补救操作:sudo apt-get install libaio1
连接时:sqlplus test/test@192.168.17.151/test

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.
