Sams Teach yourself SQL in 24hours sample database table MySQL version.
Last Update:2017-02-28
Source: Internet
Author: User
mysql| Data | database
Looking for an example of a database is really not simple. Oh
The database on the original book is just a standard, not a implemented version.
Finding this form on the web is not consistent with the type of MySQL field you find yourself using.
So I made a change. The following SQL file can be imported directly into MySQL.
With this stuff. Can save a lot of input time. It's more convenient to learn.
--study.sql files are as follows:
Create Datebase study;
Use study
--Table EMPLOYEE_TBL structure
CREATE TABLE Employee_tbl
(emp_id varchar (9) NOT NULL,
last_name varchar () NOT NULL,
first_name varchar () NOT NULL,
Middle_name varchar (15),
Address varchar is not NULL,
City varchar is not NULL,
State char (2) is not NULL,
Zip numeric (5) NOT NULL,
Phone char (10),
Pager char (10),
Constraint EMP_PK primary KEY (emp_id));
--Table EMPLOYEE_PAY_TBL structure
CREATE TABLE Employee_pay_tbl
(emp_id varchar (9) NOT NULL,
Position varchar () NOT NULL,
Date_hire date,
Pay_rate Numeric (4,2),
Date_last_raise date,
Salary numeric (8,2),
Bonus numeric (6,2),
Constraint EMP_FK foreign KEY (emp_id) references Employee_tbl (emp_id));
--Table CUSTOMER_TBL structure
CREATE TABLE Customer_tbl
(cust_id varchar) NOT NULL primary key,
Cust_name varchar () NOT NULL,
cust_address varchar is not NULL,
cust_city varchar () NOT NULL,
Cust_state char (2) NOT NULL,
Cust_zip Numeric (5) NOT NULL,
Cust_phone Numeric (10),
Cust_fax Numeric (10));
--Table ORDERS_TBL structure
CREATE TABLE Orders_tbl
(ord_num varchar) NOT NULL primary key,
cust_id varchar (TEN) is not NULL,
prod_id varchar (TEN) is not NULL,
Qty Numeric (6) NOT NULL,
Ord_date date);
--Table PRODUCTS_TBL structure
CREATE TABLE Products_tbl
(prod_id varchar) NOT NULL primary key,
Prod_desc varchar () NOT NULL,
Cost numeric (6,2) is not null);
The following is an insert record for each table.
INSERT INTO EMPLOYEE_TBL values
(' 311549902 ', ' STEPHENS ', ' TINA ', ' DAWN ', ' RR 3 BOX 17A ', ' GREEN WOOD ',
' In ', ' 47890 ', ' 3178784465 ', NULL);
INSERT INTO EMPLOYEE_TBL values
(' 442346889 ', ' plew ', ' LINDA ', ' CAROL ', ' 3301 reacon ', ' Indianapo LIS ',
' In ', ' 46224 ', ' 3172978990 ', NULL);
INSERT INTO EMPLOYEE_TBL values
(' 213764555 ', ' GLASS ', ' BRANDON ', ' SCOTT ', ' 1710 MAIN ST ', ' Whiteland ',
' In ', ' 47885 ', ' 3178984321 ', ' 3175709980 ');
INSERT INTO EMPLOYEE_TBL values
(' 313782439 ', ' GLASS ', ' JACOB ', NULL, ' 3789 white RIVER BLVD ',
' INDIANAPOLIS ', ' in ', ' 45734 ', ' 3175457676 ', ' 8887345678 ');
INSERT INTO EMPLOYEE_TBL values
(' 220984332 ', ' WALLACE ', ' MARIAH ', NULL, ' 7889 KEYSTONE AVE ',
' INDIANAPOLIS ', ' in ', ' 48741 ', ' 3173325986 ', NULL);
INSERT INTO EMPLOYEE_TBL values
(' 443679012 ', ' Spurgeon ', ' TIFFANY ', NULL, ' 5 GEORGE COURT ',
' INDIANAPOLIS ', ' in ', ' 46234 ', ' 317569007 ', NULL);
INSERT INTO EMPLOYEE_PAY_TBL values
(' 311549902 ', ' MARKETING ', ' 1989-05-23 ', null, ' 1997-05-01 ', ' 40000 ', null);
INSERT INTO EMPLOYEE_PAY_TBL values
(' 442346889 ', ' Team LEADER ', ' 1990-06-17 ', ' 14.75 ', ' 1997-06-01 ', null,null);
INSERT INTO EMPLOYEE_PAY_TBL values
(' 213764555 ', ' SALES MANAGER ', ' 1994-08-14 ', NULL, ' 1997-08-01 ', ' 30000 ', ' 2000 ');
INSERT INTO EMPLOYEE_PAY_TBL values
(' 313782439 ', ' salesman ', ' 1997-06-28 ', null,null, ' 20000 ', ' 1000 ');
INSERT INTO EMPLOYEE_PAY_TBL values
(' 220984332 ', ' shipper ', ' 1996-07-22 ', ' 11.00 ', ' 1997-07-01 ', null,null);
INSERT INTO EMPLOYEE_PAY_TBL values
(' 443679012 ', ' shipper ', ' 1991-01-14 ', ' 15.00 ', ' 1997-01-01 ', null,null);
INSERT INTO CUSTOMER_TBL values
(' 232 ', ' Leslte Gleason ', ' 798 Hardaway DR ', ' INDIANAPOLIS ',
' In ', ' 47856 ', ' 3175457690 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 109 ', ' NANCY bunker ', ' APT A 4556 waterway ', ' BROAD Ripple ',
' In ', ' 47950 ', ' 3174262323 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 345 ', ' ANGELA dobko ', ' RR3 BOX ', ' Lebanon ', ' in ', ' 49967 ',
' 7858970090 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 090 ', ' WENDY WOLF ', ' 3345 GATEWAY DR ', ' INDIANAPOLIS ', ' in ',
' 46224 ', ' 3172913421 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' ', ' Marys GIFT Shop ', ' 435 MAIN ST ', ' Danville ', ' IL ', ' 47978 ',
' 3178567221 ', ' 3178523434 ');
INSERT INTO CUSTOMER_TBL values
(' 432 ', ' SCOTT MARKET ', ' RR2 bdx 173 ', ' Brownsburg ', ' in ',
' 45687 ', ' 3178529835 ', ' 3178529836 ');
INSERT INTO CUSTOMER_TBL values
(' 333 ', ' Jasdns and DALLAS goodies ', ' LAFAYETTE SQ MALL ',
' INDIANAPOLIS ', ' in ', ' 46222 ', ' 3172978886 ', ' 3172978887 ');
INSERT INTO CUSTOMER_TBL values
(' ', ' Morgans Candies and Treats ', ' 5657 W tenth ST ',
' INDIANAPOLIS ', ' in ', ' 46234 ', ' 3172714398 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' Schylers ', ' novelties ', ' MAPLE ST ', ' Lebanon ', ' in ',
' 48990 ', ' 3174346758 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' Hollys ', ' Gamearama ', ' 567 US SOUTH ', ' Whiteland ',
' In ', ' 49980 ', ' 3178879023 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 287 ', ' gavins place ', ' 9880ROCKVILLE RD ', ' INDIANAPOLIS ',
' In ', ' 46244 ', ' 3172719991 ', ' 3172719992 ');
INSERT INTO CUSTOMER_TBL values
(' 590 ', ' heathers feathers and Things ', ' 4090 N shadeland AVE ',
' INDIANAPOLIS ', ' in ', ' 43278 ', ' 3175456768 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 610 ', ' Ragans hobbies INC ', ' 451 GREEN ST ', ' Plainfield ', ' in ',
' 46818 ', ' 3178393441 ', ' 3178399090 ');
INSERT INTO CUSTOMER_TBL values
(' 560 ', ' Andys candies ', ' RR 1 BOX ', ' Nashville ', ' in ',
' 48756 ', ' 8123239871 ', NULL);
INSERT INTO CUSTOMER_TBL values
(' 221 ', ' Ryans STUFF ', ' 2337 S SHELBY ST ', ' INDIANAPOLIS ', ' in ',
' 47834 ', ' 3175634402 ', NULL);
INSERT INTO ORDERS_TBL values
(' 56a901 ', ' 232 ', ' 11235 ', ' 1 ', ' 1997-10-22 ');
INSERT INTO ORDERS_TBL values
(' 56a917 ', ' 12 ', ' 907 ', ' 100 ', ' 1997-09-30 ');
INSERT INTO ORDERS_TBL values
(' 32a132 ', ' 43 ', ' 222 ', ' 25 ', ' 1997-10-10 ');
INSERT INTO ORDERS_TBL values
(' 16c17 ', ' 090 ', ' 222 ', ' 2 ', ' 1997-10-17 ');
INSERT INTO ORDERS_TBL values
(' 18d778 ', ' 287 ', ' 90 ', ' 10 ', ' 1997-10-17 ');
INSERT INTO ORDERS_TBL values
(' 23E934 ', ' 432 ', ' 13 ', ' 20 ', ' 1997-10-15 ');
INSERT INTO PRODUCTS_TBL values
(' 11235 ', ' Witches costume ', ' 29.99 ');
INSERT INTO PRODUCTS_TBL values
(' 222 ', ' PLASTIC PUMPKIN INCH ', ' 7.75 ');
INSERT INTO PRODUCTS_TBL values
(', ' FALSE paraffin teeth ', ' 1.10 ');
INSERT INTO PRODUCTS_TBL values
(' lighted ', ' lanterns ', ' 14.50 ');
INSERT INTO PRODUCTS_TBL values
(' Assorted costumes ', ' 10.00 ');
INSERT INTO PRODUCTS_TBL values
(' 9 ', ' CANDY CORN ', ' 1.35 ');
INSERT INTO PRODUCTS_TBL values
(' 6 ', ' PUMPKIN CANDY ', ' 1.45 ');
INSERT INTO PRODUCTS_TBL values
(' PLASTIC ', ' SPIDERS ', ' 1.05 ');
INSERT INTO PRODUCTS_TBL values
(' 119 ', ' assorted masks ', ' 4.95 ');