Database Reference
In-Depth Information
B
APPENDIX
SQL REFERENCE
You can use this appendix to obtain details concerning important components and syntax for SQL. Items are
arranged alphabetically. Each item contains a description and, where appropriate, both an example and a
description of the query results. Some SQL commands also include a description of the clauses associated with
them. For each clause, there is a brief description and an indication of whether the clause is required or optional.
ALTER TABLE
Use the ALTER TABLE command to change a table
s structure. As shown in Figure B-1, you type the ALTER
TABLE command, followed by the table name, and then the alteration to perform. (Note: In Access, you usu-
ally make these changes to a table in Design view rather than using ALTER TABLE.)
'
Clause
Description
Required?
ALTER TABLE
table name
Indicates the name of the table to be altered.
Yes
alteration
Indicates the type of alteration to be performed.
Yes
FIGURE B-1
ALTER TABLE command
The following command alters the Customer table by adding a new column named CustType:
ALTER TABLE Customer
ADD CustType CHAR(1)
;
The following command alters the Customer table by changing the length of the CustomerName column:
ALTER TABLE Customer
CHANGE COLUMN CustomerName TO CHAR(50)
;
The following command alters the Part table by deleting the Warehouse column:
ALTER TABLE Part
DELETE Warehouse
;
COLUMN OR EXPRESSION LIST (SELECT CLAUSE)
To select columns, use a SELECT clause with the list of columns separated by commas. The following
SELECT clause selects the CustomerNum, CustomerName, and Balance columns:
SELECT CustomerNum, CustomerName, Balance
Use an asterisk in a SELECT clause to select all columns in the table. The following SELECT command
selects all columns in the Part table:
SELECT *
FROM Part
;
Search WWH ::




Custom Search