300
Part II: Building Databases and Working with Data
Results:
Address1 City StateAbbrev County PostalCode
------------------------- ------------- ----------- ---------- ----------
137 Lancelot Dr Phoenix AZ Sunshine 85004
25250 N 90th St Scottsdale AZ Sunshine 85257
253731 West Bell Road Surprise AZ Sunshine 85374
2551 East Warner Road Gilbert AZ Sunshine 85233
3294 Buena Vista Lemon Grove AZ Sunshine 85284
4584 Hamiliton Ave. Chandler AZ Sunshine 85225
6441 Co Road Lemon Grove AZ Sunshine 85252
6500 East Grant Road Tucson AZ Sunshine 85701
7656 Ramsey Circle Chandler AZ Sunshine 85225
7709 West Virginia Avenue Phoenix AZ Sunshine 85004
7750 E Marching Rd Scottsdale AZ Sunshine 85257
870 N. 54th Ave. Chandler AZ Sunshine 85225
9228 Via Del Sol Phoenix AZ Sunshine 85004
9980 S Alma School Road Chandler AZ Sunshine 85225
Arcadia Crossing Phoenix AZ Sunshine 85004
Factory Stores Of America Mesa AZ Sunshine 85201
Factory Stores/tucson Tucson AZ Sunshine 85701
Prime Outlets Phoenix AZ Sunshine 85004
Creating a Default Row
SQL includes a special form of the INSERT command that creates a single new row with
only default values. The only parameter of the new row is the table name. Data and column
names are not required. The syntax is simple, as shown here:
INSERT schema.Table DEFAULT VALUES;
I have never used this form of INSERT in any real-world applications. It could be used
to create “pigeon hole” rows with only keys and null values, but I don’t recommend that
design.
Creating a Table While Inserting Data
The last method to insert data is a variation on the SELECT command. The INTO select
option takes the results of a SELECT statement and creates a new table containing the
results. SELECT...INTO is often used during data conversions and within utilities that
must dynamically work with a variety of source-table structures. The full syntax includes
every SELECT option. Following is an abbreviated syntax to highlight the function of the
INTO option:
SELECT Columns
INTO NewTable
FROM DataSources
[WHERE conditions];
c12.indd 300c12.indd 300 7/30/2012 4:42:39 PM7/30/2012 4:42:39 PM
http://www.it-ebooks.info