Access the MS SQL Server database under Linux (transfer)

zhaozj2021-02-16  55

Access MS SQL Server Database Under Linux

---- Linux as a free Unix operating system, with its open source code, multitasking, X-swindow, etc., and many companies use Linux to serve as a full function of its internal network. Servers (WWW, FTP, Email, DNS). The inner network of enterprises is not only to provide access to text information, and it is also possible to provide an interview with information in the database of enterprises. SQL Server uses its low-cost, high-performance and equivalent of NT to be used as many companies, but Microsoft does not provide customers under its UNIX, which is difficult to bring such applications. This article has raised the solution of this question. Install Sybase Nice ---- First first from Microsoft SQL Server and Sybase SQL Server. Two companies have developed the data library SQL Server for OS / 2 on OS / 2. After the two companies open the upgrade system, Sybase's customer can access Microsoft SQL Server. ---- Compared with other database companies, you can say that Sybase is the most kindly of Linux, which does not provide SQL Server under Linux, but provides free CT -LIB clients, which may also be many IT managers do no longer consider one of Oracle or Informix for the company's database option. It is now changed in the situation. ---- Sybase released OpenClient for Linux is a.out format, which transforms them into ELF and dynamic links, and looks for download from the following addresses: http://www.mbay. NET / ~ MPEppler. At the same time, the two versions are best downloaded. When you use a dynamic link, you can use a dynamic link. However, you can need a library (libblk.a) while compiling, only in the ELF.

---- After downloading, type the following command to expand (assuming the current directory is / usr / tmp): ---- TAR ZXVF Linux elf  Dynamic TAR.GZ ---- then move it to / usr / local Directory: ---- MV Sybase / USR / LOCAL ---- Compile and use the Sybase client to make the following settings: ---- 1. Interface files are as follows: ---- MSSQL ---- Query TCP Ether MySQL 1433 ---- Among them: MSSQL is the server name used by the client, and then references MSSQL; MySQL is the address or name of the server, if Name, the system can find its IP address; 1433 is the port number of SQL Server, the default value of Microsoft SQL Server is 1433, Sybase is 5000. ----2 . Sybase environmental variable, the content is the directory of the Sybase customer: --- export sybase = / usr / local / sybase ---- 3. If you have the example in the Sybase customer, you will also set the ring-wide variable sybplatform: ---- Export Sybplatform = Linux ---- and modified the name of the server name and the description of the server name and the password. Use the SQSH interface to access the SQL Server ---- Sybase client provides XISQL tools, but more people use SQSH, SQSH is the abbreviation of Sqshell, is an improved ISQL, downloaded from the following address: http: // Www.voicenet.com/ ~ gray /. The latest version of the front is 1.6.0. Assume that the downloaded file is placed under the / usr / tmp: ---- TAR ZXVF SQSQ 1.6.0 t. ---- CD SQSH 1.6.0 ----./ Configure ---- Make; Make Install ---- then install the generated executable SQSH to / usr / local / bin / directory. ---- SQSH is as follows: ---- # Sqsh - -uuserName - -ppassword - -ssserName ---- UserName and Password are user names and passwords, ServerName is the server name defined in the interface file (such as example MSSQL in. ---- SQSH is the interactive command line interface, and the command will use the input Go to execute. If the command is longer, it can be directly divided into several books and write it.

---- as follows: ---- 1> USE PUBS ---- 2> GO ---- 1> Select * from authors ---- 2> Go adopt CT -LIB writing applications - - Since Sybase's Linux client does not provide DB -Library, CT -Library should be used to write applications, using CT -Library to write applications for reference examples, detailed programming instructions can be referred to Sybase. Use Sybperl to write applications ---- Sybperl is Sybase's Perl expansion, which can use Perl words to access SQL Server, or write CGI program. ---- Sybperl can get http://www.mbay.net/ ~ mpeppler from the following address. The latest version of the front is 2.9.5. ---- After the Sybper's source code is expanded, you need to modify the config file. The following is a few parameters: ---- The next file to be modified is PWD, this is used to test, the server name , User name, user password is set to its own configuration. After the completion: ---- Perl makefile.pl ---- make; make test; make install ---- installs the success of the SYBPERL can be used. The lower surface is a simple example. #! / Usr / bin / perl use sybase :: ctlib; $ dbh = new Sybase :: CTlib 'sa', '', 'mssql'; $ dbh -> ct_execute ("SELECT AU_ID, AU_LNAME, AU_FNAME FROM PUBS.DBO .authors "); While ($ dbh -> ct_results ($ restype) == cs_succeed) {next unless $ dbh -> ct_fetchable ($ restype); while ($ AU_ID, $ AU_LNAME, $ AU_FNAME) = $ dbh -> CT_FETCH) {Print "$ AU_ID - $ AU_LNAME AU_FNAME / N";}} --- It can be seen that a few lines of statement can complete the operation of the database. ---- From several aspects to visit the MS SQL Server data library in Linux, the basic API program is introduced, and the SQSH command line is interviewed, and Perl Access.

转载请注明原文地址:https://www.9cbs.com/read-21057.html

New Post(0)