The Wayback Machine - https://web.archive.org/web/20071011015523/http://sqlcourse.com:80/insert.html


Free Newsletters:
DatabaseJournal
DBANews
 

SQLCourse
Interactive Online SQL Training
HOME News MS SQL Oracle DB2 Access MySQL PHP SQL Etc Scripts Links Forums DBA Talk
internet.com
SQL Courses
1 What is SQL?
2 Table basics
3 Selecting data
4 Creating tables
5 Inserting into a table
6 Updating records
7 Deleting records
8 Drop a table
9 Advanced Queries
10 Standalone SQL interpreter
11 Advertise on SQLCourse.com
12 Database Links
13 Technology Jobs




internet.commerce
Partner With Us
Dental Insurance
Mortgage Refinance
Cars
Server Racks
Computer Deals
GPS Devices
KVM over IP
Memory Upgrades
Laptop Batteries
Custom Products
PDA Phones & Cases
GPS
Mp3 Player Reviews
Graphics Cards

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Whitepaper: Extending the Enterprise Network Through Mobility. Get an innovative approach to designing next-gen networks, based on the 2 key principles of command from the center & control to the edge.
ITIL v3 WEBINAR:
Service Operations Are Key for Great Management

WHITEPAPER:
ITIL v3--The Next Chapter in IT Service Management

WHITEPAPER:
5 Essential Questions for choosing an ITIL Service Provider

ITSM GUIDE:
Benefits to the ITIL Approach to Service Management

WHITEPAPER:
Determining the Return on Investment from Deploying Integrated ITSM

Inserting into a Table

The insert statement is used to insert or add a row of data into the table.

To insert records into a table, enter the key words insert into followed by the table name, followed by an open parenthesis, followed by a list of column names separated by commas, followed by a closing parenthesis, followed by the keyword values, followed by the list of values enclosed in parenthesis. The values that you enter will be held in the rows and they will match up with the column names that you specify. Strings should be enclosed in single quotes, and numbers should not.

insert into "tablename"
 (first_column,...last_column)
  values (first_value,...last_value);

In the example below, the column name first will match up with the value 'Luke', and the column name state will match up with the value 'Georgia'.

Example:

insert into employee
  (first, last, age, address, city, state)
  values ('Luke', 'Duke', 45, '2130 Boars Nest', 
          'Hazard Co', 'Georgia');

Note: All strings should be enclosed between single quotes: 'string'

Insert statement exercises

It is time to insert data into your new employee table.

Your first three employees are the following:

Jonie Weber, Secretary, 28, 19500.00
Potsy Weber, Programmer, 32, 45300.00
Dirk Smith, Programmer II, 45, 75020.00

Enter these employees into your table first, and then insert at least 5 more of your own list of employees in the table.

After they're inserted into the table, enter select statements to:

  1. Select all columns for everyone in your employee table.
  2. Select all columns for everyone with a salary over 30000.
  3. Select first and last names for everyone that's under 30 years old.
  4. Select first name, last name, and salary for anyone with "Programmer" in their title.
  5. Select all columns for everyone whose last name contains "ebe".
  6. Select the first name for everyone whose first name equals "Potsy".
  7. Select all columns for everyone over 80 years old.
  8. Select all columns for everyone whose last name ends in "ith".

Create at least 5 of your own select statements based on specific information that you'd like to retrieve.

Answers to these exercises

SQL Interpreter


SQL Course Curriculum
<<previous 1 2 3 4 5 6 7 8 9  next>>


Solutions


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info