What is the INSERT statement? How do I use it?
The INSERT
statement lets you insert information
into a database. A few examples are shown belowINSERT INTO people VALUES ('Bush', 'George', 47 , 'White
House', 'Washington')
Would insert a new row at the bottom of the table people consisting
of the values in parentheses in the above statement.INSERT INTO people (lastname, city) VALUES ('Gates', 'Redmond')
Would insert a new row at the bottom of the table people consisting of
only 2 values as present in the above statement, namely 'Gates' and 'Redmond'.
The remaining columns for that particular record would be left empty (null).
Note : A null value is different from 0 or ''(Empty String). A perfect
example of this would be a column describing the hair colour for many people.
In case the person is bald then the value of the colour should be null rather
than empty. This would be perfect from the database design view. A particular
entity which doesn't exist should be represented similarly and not by empty Strings.
How do I delete a record from a database?
Use the DELETE
statement to remove records or any
particular column values from a database.DELETE FROM people WHERE lastname = 'Hunter'
Would remove the entire record which represents any person whose lastname
is 'Hunter'. In our case it would remove 1 record from the sample database table
people. It would remove all the values that were a part of that record.
Is there a way to update any record in a database?
Yes. You could use the UPDATE
statement. The update
statement updates (or replaces) those values that were specified in the SQL statement
with the new values provided.UPDATE people SET age = 50, city = 'Mumbai' WHERE (lastname
= 'Hunter' AND firstname='Jason')
Would change Jason Hunter's age from 41 to 50 and would make him shift
his residence from 'San Jose' to 'Mumbai'. Isn't that cool?? A new Java Guru
is Mumbai !!
SQL In Simple English
- Introduction
- Lets get started
- Basic SELECT statements
- Inserting, Deleting & Updating
- More Advanced SQL
- Show me more!
Inserting, Deleting & Updating
You might also like...
SQL books
-
SQL Architecture Basics Joes 2 Pros: Core Architecture concepts (Sql Exam Prep Series) (Volume 3)
As companies grow and do more business, the data they store in databases similarly grows. If you want to be a go-to person on the inner workings of SQL Server, then this book will be your partner in achieving that goal. If you have completed the SQL ...
SQL forum discussion
-
Oracle 10 - Web service
by markisun35 (2 replies)
-
Required Every quarter data from sql automatically in below sql format
by jain.piyush831 (0 replies)
-
Which is harder to learn Java or C++ ?
by surbhinahta (114 replies)
-
C ++ public int __cdecl printf (const char * __restrict__ _Format, ...) problem.
by sgameyta (0 replies)
-
Is Your Data is Lost? Learn Online How TO Recover Your Data.
by dataempires (0 replies)
SQL podcasts
-
webdev radio: SQL Cookbook review, Aardvark, MySQL tuning, CSS question
Published 8 years ago, running time 0h20m
We have the first book giveaway and cover the Aardvark Firefox extension. I also explain some MySQL performance problems I’ve had recently, talk about some MySQL tools which helped me get over those problems, and ask for some help on a CSS layout question. *CSS Creator Layout Generator :: Ge.
SQL jobs
-
Graduate Reports Developer
Jagex in Cambridge, United Kingdom
To £30k (DOE) + Excellent Benefits / Progression -
Data Architect
Integrative Nutrition in New York, United States
Competitive
Comments