Notes on Informix Learning

Source: Internet
Author: User
Tags informix import database

Notes on Informix Learning:

One, start the Shutdown database script

Start: OnInit

Close: onmode-k

two. Import and Export DatabaseExport Database

Export the database Public_bak to the directory/usr/informix/export:

$ dbexport Public_bak-o/usr/informix/export

At the end of execution, a pubic_bak.exp directory is generated in the export directory. In this directory, there are statements and data for database creation objects.

$ pwd

/usr/informix/export

$ ls

Public_bak.exp

$ CD Public_bak.exp

$ lc

BANK_00104.UNL issu_00102.unl SECU_00136.UNL sz_fu00130.unl ZLS_R00123.UNL

B_SEC00134.UNL mer_b00101.unl SECU_00139.UNL sz_op00131.unl ZLS_T00124.UNL

CARD_00103.UNL offli00115.unl SETTL00108.UNL sz_se00137.unl ZLS_T00126.UNL

CHILD00107.UNL pos_i00105.unl SETTL00109.UNL telle00106.unl ZLS_W00122.UNL

FILE_00116.UNL public_bak.sql SETTL00110.UNL test_00120.unl ZLS_W00125.UNL

FILE_00117.UNL resp_00112.unl SETTL00111.UNL trans00114.unl ZLS_W00127.UNL

FILE_00118.UNL secub00132.unl SYSME00140.UNL trans00138.unl ZLS_W00128.UNL

FILE_00119.UNL SECUB00133.UNL SYSME00141.UNL TXN_I00113.UNL

HIST_00100.UNL SECU_00135.UNL SZ_CU00129.UNL ZLS_H00121.UNL

$

Import Database?

Import Database: Dbimport

Mount the Public_sto subdirectory under the/usr/informix/export directory into the Public_sto database. Assume that the schema file is/usr/informix/export/public_sto.exp/public_sto.sql. Use the following command to import the library:

$ dbimport public_sto-c-i/usr/informix/export

In this way, both the object and the data are imported into the database.

Import data into the database: Dbload

$ cat Test_c1.sql

FILE test_c1.unl DELIMITER ' | ' 2;

INSERT into Test_c;

$ cat TEST_C1.UNL

13| Tom

14| James

$

Import the records from TEST_C1.UNL into the table Test_c of the database Public_bak:

$ dbload-d public_bak-c Test_c1.sql

Dbload Load Utility informix-sql Version 7.30.uc2

Copyright (C) Informix Software, Inc., 1984-1998

Software Serial number aac#j495018

Error Logging File Name:test_c1

In INSERT statement number 1 of the raw data file TEST_C1.UNL.

Row number 3 is bad.

||

Reached unexpected end of line while reading field

Table Test_c had 2 row (s) loaded into it.

$

Of course, you can also add parameters to specify the output log:

$ dbload-d public_bak-c test_c1.sql-l Test_c1.log

Third, export the Import database object?Export database objects?

Export Database object: Dbschema

If you want to output the table Test_c statement in the database Public_bak, you can use the following statement:

$ dbschema-t test_c-d Public_bak-ss Test_c2.sql

DBSCHEMA Schema Utility informix-sql Version 7.30.uc2

Copyright (C) Informix Software, Inc., 1984-1998

Software Serial number aac#j495018

$ VI Test_c2.sql

"Test_c2.sql" lines, 268 characters

{TABLE "Informix". Test_c Row Size = number of columns = 2 index size = 0}

CREATE TABLE "Informix". Test_c

(

ID integer

Default 0,

Name Char (20)

) Extent size + Next size + lock mode page;

Revoke all on the "Informix". Test_c from the "public";

Import Database objects?

object to import Database: Dbschema

For example: Database object creation file content is as follows:

$ cat Test_c2.sql

{TABLE "Informix". Test_c Row Size = number of columns = 2 index size = 0}

CREATE TABLE "Informix". Test_c

(

ID integer

Default 0,

Name Char (20)

);

Revoke all on the "Informix". Test_c from the "public";

The command to import the object is as follows (Public_bak is the database name and Test_c2.sql is the object file):

$ dbaccess Public_bak Test_c2.sql

Database selected.

Table created.

Permission revoked.

Database closed.

$

four. Export Import database data?Export data?

To export data from a database table: Unload

Using the isql or dbaccess command, go to the Informix Operations database operator interface and select the table data that needs to be exported. For example: Export the data from the table Test_c to the file Test_c3.dmp file:

Unload to ' test_c3.dmp ' select * from Test_c;

$ cat Test_c3.dmp

11| james|

12| david|

13| Tom|

14| james|

15| standand|

16| stone|

$

Import data?

Import Table data: Load

Execute the command in the same way as unload. For example, import the data from the Test_c3.dmp file into table Test_c:

Load from ' test_c3.dmp ' insert into test_c;

Check to verify:

SELECT * FROM Test_c

ID Name

James

David

Tom

James

Standand

Stone

Create a new stored procedure:

$ VI Test_proc.sql

"Test_proc.sql" lines, 168 characters

CREATE PROCEDURE "Informix". Test_proc_a ()

returning int;

define x int;

Let x=16;

INSERT into Test_c values (x, ' Rolex ');

return x;

End procedure;

$ dbaccess Public_bak Test_proc.sql

Database selected.

Routine created.

Database closed.

$

Execute stored procedure: Use command dbaccess to log in to the database's interactive environment first. Perform:

Execute procedure test_proc_a ();

Execution Result:

(expression)

16

Jesus loves you!

"What good is it for a man to earn the whole world and lose his life?" What else can a man change for life? "The Bible" (Matthew 16:26)

Notes on Informix Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.