Database Reference
In-Depth Information
C H A P T E R 4
Manipulating Database Data
Now that you know how to create databases and tables, it's time to turn your attention to modifying
data, such as inserting, updating, and deleting it.
In this chapter, we'll cover the following:
Inserting data
Updating data
Deleting data
Inserting Data
After creating a table, you need to be able to add data such as rows to a table. You do this by using the
INSERT statement.
A basic INSERT statement has these parts:
INSERT INTO <table>
(<column1>, <column2>, ..., <columnN>)
VALUES (<value1>, <value2>, ..., <valueN>)
Using this syntax, let's add a new row to the MySqlTable table of the newly created SQL2012Db
database.
Try It: Inserting a New Row
To insert a new row into a table, open a New Query window in SQL Server Management Studio. Enter
the following query, and click Execute:
Use SQL2012Db
Go
insert into MySqlTable ( Name, Age, SSN, Date, Gender )
Values('Vidya Vrat',36,'111-20-3456',GetDate(),'Male')
Go
Executing this statement in the query pane should produce a Messages window reporting “(1 row(s)
affected),” as shown in Figure 4-1.
 
Search WWH ::




Custom Search