247
C H A P T E R 8
Data Modification
S
QL has a set of statements known as Data Manipulation Language (DML) that deals with, well, data
manipulation. Some people think that DML involves only statements that modify data, but in fact it
also involves data retrieval. DML includes the statements SELECT, INSERT, UPDATE, DELETE, TRUNCATE,
and MERGE. Up to this point in the book, I’ve focused on the SELECT statement. This chapter focuses
on data modification statements. In addition to covering standard aspects of data modification, in this
chapter, I’ll also cover aspects specific to T-SQL.
To avoid changing data in your existing sample databases, for demonstration purposes, most of
the examples in this chapter create, populate, and operate against tables in the TSQL2012 database
that use the dbo schema.
Inserting Data
T-SQL provides several statements for inserting data into tables: INSERT VALUES, INSERT SELECT,
INSERT EXEC, SELECT INTO, and BULK INSERT. I’ll first describe those statements, and then I’ll talk
about tools for automatically generating keys, such as the identity column property and the se-
quence object.
Do'stlaringiz bilan baham: |