Friday, March 02, 2007

Insert a Row into a Database Table

Inserting a row into a database table is a fairly easy task as long as the the parent keys are populated. In this example, we assume the parent keys have been populated. Here's an illustration.

ORACLE
SQL> insert into CUSTOMER VALUES (10001,'GM',628,'111-0000',628,'111-1111','123 Main St.','3-12-1999','111-11-1111',89897);

SYBASE
1> insert into CUSTOMER VALUES (10001,'GM',628,'111-0000',628,'111-1111','123 Main St.','3-12-1999','111-11-1111',89897)
2>go

If the parent key(s) is/are not populated, you will get an "integrity constraint violated - parent key not found" error.

The ";" is the execute command for Oracle and "go" is the execute command for Sybase.

No comments: