Chapter 1: SQL Building Blocks  Tables, columns, and rows

Chapter 1: SQL Building Blocks

Queries, data modification, and commands

In SQL, a query requests data using the select command. For example, this query asks for a listing of authors who live in the state of California:

select au_lname, city, state 
from authors 
where state = "CA" 

Data modification refers to the addition, deletion, or change of data using the insert, delete, or update commands. For example:

insert into authors (au_lname, au_fname, au_id)
values ("Smith", "Gabriella", "999-03-2346")

Other SQL commands, such as dropping tables or adding users, perform administrative operations. For example:

drop table authors 

Each command or SQL statement begins with a keyword, such as insert, that names the basic operation performed. Many SQL commands also have one or more keyword phrases, or clauses, that tailor the command to meet a particular need. When you run a query, Transact-SQL displays the results. If no data meets the criteria specified in the query, you see a message to that effect. Data modification statements and administrative statements do not retrieve data, and therefore, do not display results. Transact-SQL provides a message to let you know whether the data modification or other command has been performed.





Copyright © 2005. Sybase Inc. All rights reserved. Tables, columns, and rows

View this book as PDF