|
SQL Script for the Welcome to Introduction to SQL. Here you will find the SQL script
to create and populate the tables used in the course. In order
for you to run each of the examples in the course, you need to create
four tables. With the exception of the Customer2 table, all of the following
tables must be populated with records: Customer,
ServicePlans, Orders
and Customer2. Note: If you are using Microsoft Access 2003 or a later version, further down the page there is an option to download the course database as opposed to copying and pasting the SQL script into Microsoft Access.
Locate interface for SQL script:
Download the Microsoft Access "2003", "2007", or "2010" Course Database: If you are using Microsoft Access 2003, 2007, or 2010 you have the option to download the course database from the following links: Save the file to your desktop. Next, open the file from your desktop or from the pop-up box that appears after the download. Go to "SQL View" to run the queries in the lessons. Note: The Customer table contains 2 additional records (12, 13) that will not be needed until lesson 7 and 8. Note: The ServicePlans table contains 1 additional record (E1001) that will not be needed until lesson 7 and 8.
Create the Course Database Tables Using SQL Script: In order to create and populate the Customer table,
you must first copy, paste and run
the Create Table script for the Customer table. Next, delete the
Create Table script and copy, paste and run each Insert Statement ONE
AT A TIME (Some DBMSs such as Microsoft SQL Server, allow you to run several inserts statements at the same time) to populate the Customer table. Each Insert Statement
is separated by a semi colon. Note: In some versions of Microsoft Access you may have to set your primary key in the Create Table scripts using the following method: CustomerID INTEGER NOT NULL CONSTRAINT PriKey Primary Key, **Follow the same preceding steps to create and populate the ServicePlans, and Orders tables. Create the Customer2 table, but do not populate it. The Customer2 table will be populated in lesson eight. Important: Read the important notes below before you begin.
CUSTOMER CREATE TABLE SCRIPT CREATE TABLE Customer
CUSTOMER TABLE INSERT STATEMENTS INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) NOTE: The Customer table in lesson 7 and 8 contains 2 extra records. Below you will find the two extra records. You can add the records now or you can add them when you get to lessons 7 and 8. Adding the records now is not a problem as long as you remember that you added them since you may see the records in some of your results. INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode) INSERT INTO Customer (CustomerID, FirstName, LastName, HomePhone, Address,
State, City, PostalCode)
|