This command reference, designed for users of all levels, provides a user-friendly guide to the SQL database programming language. All commands will be listed alphabetically by functional area -- ideal for beginners who can locate commands based on the tasks they are trying to accomplish. In addition, the author has included a "roadmap" listing commands in alphabetical order at the front of the book that is ideal for more advanced users who know the command name and simply need to know a page number. Each command will include a hands-on example. The book reflects the new SQL standard, and should be one of the very first books on the market. Author includes extensive examples for Oracle and Microsoft SQL Server implementations. This 6x9 reference is the perfect companion to Bowman's Practical SQL Handbook and is design to fit on the busy Database Developer's desk.
1. RDBMS Concepts — A Primer.
Database Management System Background. Brief History of Relational DBMSs and SQL Language. SQL Language. Where Does SQL Fit In? Chronology of SQL Standards. SQL Server 2000 Product Line. Client-Server Architecture. Three-Tier Client-Server Architecture. RDBMS: Tables and Databases. Tables in a Database. Databases in Microsoft SQL Server. The SQL Language and MSS's Transact-SQL. Comments. Data Types — First Look. Domain and NULL Values. Metadata and Data. Data Definition Language (DDL) and Data Manipulation Language (DML). DDL Examples—CREATE TABLE, ALTER TABLE, DROP TABLE. DML Examples—INSERT, UPDATE, DELETE, SELECT. Case Sensitivity in SQL Statements. RDBMS Utility to Show Table Structure. Lab Exercises. Lab Exercise 1: Introduction to Using Microsoft SQL Server. Lab Exercise 2: CREATE TABLE. Lab Exercise 3.
SQL Server Instance. The SQL Server Database. Data Representation. General Data Type Information. Domain and NULL Value. Constant (Literal) Defined. Identifiers—Naming SQL Objects. Using Identifiers as Qualified Object Names. Expressions in an SQL Statement. Operators. SQL Server 2K Data Types. Numeric Data Type Overview. String Data Type Overview. Other Data Type Overview. Transact-SQL Data Type Precedence. Transact-SQL Data Type Hierarchy. BIGINT, INT, SMALLINT and TINYINT Details. BIT Data Type Details. DECIMAL and NUMERIC Data Type Details. MONEY and SMALLMONEY Data Type Details. FLOAT and REAL Data Type Details. DATETIME and SMALLDATETIME Data Type Details. CHAR and VARCHAR Data Type Details. NCHAR and NVARCHAR Data Type Details. SYSNAME Data Type Details. TEXT, NTEXT and IMAGE Data Type. BINARY(n) and VARBINARY(n) Data Type Details. CURSOR Data Type Details. SQL_VARIANT Data Type Details. TABLE Data Type Details. TIMESTAMP (ROWVERSION) Data Type Details. UNIQUEIDENTIFIER Data Type Details. User-Defined Data Types. Enterprise Manager—Create and Manage a User-Defined Data Type. Transact-SQL—Create and Manage a User-Defined Data Type. Transact-SQL Functions. Aggregate Functions. Cursor Functions. Configuration Functions. Date and Time Functions. Mathematical Functions. Metadata Functions. Rowset Functions. Security Functions. String Functions — for CHAR or VARCHAR expressions. System Functions. System Statistical Functions. Text and Image Functions and Statements. Deterministic and Nondeterministic Functions. CASE Expression. CAST and CONVERT. System Stored Procedures and DBCC. System Stored Procedures. DBCC. Server, Database and Session Settings. Settings Overview. Database Configuration (Database Properties). Session (Connection) Configuration Settings. Default Nullability of New Columns in a Table. Collation.
Data Definition Language (DDL). Metadata and Data. Types of Objects Managed by DDL. sp_detach_db and sp_attach_db. CREATE, ALTER, DROP DATABASE. sp_bindefault and sp_unbindefault. CREATE, DROP DEFAULT. CREATE, ALTER, DROP FUNCTION. Query Analyzer Debugger Functions (UDF). CREATE, DROP INDEX. CREATE, ALTER, DROP PROCEDURE. Query Analyzer Stored Procedure DebuggerDebugger. CREATE RULE, DROP RULE, sp_bindrule. CREATE SCHEMA. CREATE, UPDATE, DROP STATISTICS. STATS_DATE. CREATE, ALTER, DROP TABLE. CREATE, ALTER, DROP TRIGGER. CREATE, ALTER, DROP VIEW. Indexed View. PARTITIONED VIEWS. Displaying Metadata. System Stored Procedures to Display Metadata. ANSI Information Schema Views. Metadata Functions. SELECT statements on the system tables. Using Enterprise Manager to Observe Metadata. Security. Client Program Login to SQL Server. SQL Server Authentication Mode Options. Database Level Access. Roles. Creating Logins and Roles. Chapter Lab Exercises. Lab Exercise 1: CREATE TABLE emps3, depts3.
INSERT. INSERT Syntax. INSERT and SELECT with an IDENTITY Column. UPDATE. UPDATE—Basic Syntax. UPDATE—Complete Syntax. DELETE. DELETE Syntax. TRUNCATE TABLE. TRUNCATE TABLE Syntax. SELECT. SELECT Statement Syntax. Column Aliases. SET Operations. SET Operations — UNION, UNION ALL. SET Operations — INTERSECTION. SET Operations — SET DIFFERENCE. Hints—Join Hints, Query Hints and Table Hints.
Transaction Control—ANSI SQL and MSS. Transaction Concepts. Starting and Ending a Transaction. ISOLATION Is Obtained through Locking. Automatic (Implicit) Transaction Mechanisms. Explicit Transaction Mechanisms. Transaction Control: Isolation Levels. Defining Isolation Levels. Implementation of the Isolation Levels Using Locks (MSS). Setting Isolation Level. Server Shutdown. MSS 2000. MSS 7. @@version. Identifying Version and Service Pack. BACKUP AND RESTORE. File System Backup vs Database Backup. Database Backup. Types of SQL Server Database Backup. Transaction Log Backup (TLBU). MSS 2000 Recovery Models. BACKUP DATABASE, BACKUP LOG. BACKUP DATABASE. BACKUP LOG. Truncate Log—Emptying the Transaction Log. BACKUP—1. Backup Dialog. RESTORE DATABASE. RESTORE LOG. Restore Dialog. RESTORE Command. Restore Using Example Backup Strategy. Comments about Backup and Restore. Database Layout for Performance and Restorability. RAID. Production Database—Suggested Disk Layout 1. Production Database—Suggested Disk Layout 2. Introduction to Transact-SQL Programming. Batches. EXEC[UTE]. Two forms of SQL Comments. PRINT. Variables. Program Flow Control. BEGIN - END. RETURN. IF-ELSE. WHILE, BREAK, CONTINUE. GOTO and Labels. WAITFOR. Example TRANSACT-SQL Stored Procedure. Error Handling. Managing Error Messages. sp_addmessage, sp_altermessage, sp_dropmessage. @@ERROR. RAISERROR. Cursors. SQL-92 Cursor. Transact-SQL Extended Cursor (T-SQL Cursor). Commands Used with Cursors. Cursor Functions and Stored Procedures. Dynamic SQL.