D.2. Inserting Data into a Table
USE sysadm INSERT hosts VALUES ( 'shimmer', '192.168.1.11', 'shim shimmy shimmydoodles', 'David Davis', 'Software', 'Main', '309', 'Sun', 'Ultra60' )
The first line tells the server we are going to work with objects in the sysadm database. The second line selects the hosts table and adds a row, one column at a time. This version of the INSERT command is used to add a complete row to the table (i.e., one with all columns filled in). To create a new row with a partial record we can specify the columns to fill, like so:
USE sysadm INSERT hosts (name,ipaddr,owner) VALUES ( 'bendir', '192.168.1.3', 'Cindy Coltrane' )
INSERT can also be used to add data from one table to another; we'll see this usage later. For the rest of our examples, assume that we've fully populated the hosts table using the first form of INSERT.
Copyright © 2001 O'Reilly & Associates. All rights reserved.