3 4
Chapter 16
Defaults, constraints, and rules are optional attributes that you can define on database columns and tables. Chapter 15 showed you a little bit about defaults by describing how to add a column with a default value to a table by using the ALTER TABLE command. In this chapter, you'll learn the two methods for creating and modifying defaults. As you'll recall, defaults are values inserted into a particular column when no value is explicitly entered. Constraints provide methods for identifying valid values for a column (in order to reject invalid values) and for enforcing data integrity within database tables and between related tables. We'll look at the five types of constraints in this chapter, and you'll learn how to create and modify defaults and constraints by using both Transact-SQL (T-SQL) and Microsoft SQL Server Enterprise Manager, although using Enterprise Manager is often simpler.