SQL PRIMARY KEY and CHECK Constraints

RosyPrologue6564 avatar
RosyPrologue6564
·
·
Download

Start Quiz

Study Flashcards

27 Questions

What is the purpose of the DEFAULT clause in a CREATE TABLE statement?

To define a default value for a column when no value is specified

What type of expression can be used to specify a default value in a DEFAULT clause?

A constant, a built-in function, or a mathematical expression

Where is the DEFAULT clause specified in a CREATE TABLE statement?

Within the declaration of the column, together with the data type and other column properties

What happens if you omit the DEFAULT keyword when creating a default definition in a CREATE TABLE statement?

The database engine assigns an implicit name for the default

What is the purpose of the CONSTRAINT option in a CREATE TABLE statement when creating a default definition?

To assign a name to the default constraint

Can a default value be specified for a column that has a PRIMARY KEY constraint?

Yes, and the default value is ignored if a value is specified during an INSERT operation

What happens when a default value is specified for a column and a value is also specified during an INSERT operation?

The specified value is used, and the default value is ignored

Can a default value be specified for a column that has a FOREIGN KEY constraint?

Yes, and the default value is ignored if a value is specified during an INSERT operation

What is the main benefit of using a default value for a column?

It simplifies data entry by providing a default value when no value is specified

What is the primary function of an index in a relational database?

To allow efficient access to data stored on a disk

What type of database object is derived from one or more base tables?

View

What is the purpose of the FOREIGN KEY constraint in the works_on1 table?

To create a relationship between the employee and project tables

What is the result of deleting a parent table row that has a related row in the works_on1 table?

The related row in works_on1 is deleted

What is the purpose of a stored procedure in a relational database?

To execute a sequence of statements written in Transact-SQL

What is the result of updating a parent table row that has a related row in the works_on1 table?

The related row in works_on1 is updated

What are the two types of database objects?

Physical and Logical

What is the first database object that needs to be created?

Database

What type of databases can an authorized user create?

User databases

What is managed by the Database Engine?

Both system and user databases

What is an example of a logical object?

Table

What are the system databases generated during the installation of the database system?

tempdb, model, and msdb

What is the maximum size of a database name in SQL Server?

128 characters

What is the purpose of the PRIMARY option in the CREATE DATABASE statement?

To specify the first file that contains system tables and other important internal information

What is the original size of the projects_dat file in the example?

10MB

What is the method used to create a database in SQL Server Management Studio?

Using Object Explorer

What is the file name of the log file in the example?

projects.ldf

What is the file growth rate for the projects_dat file in the example?

5MB

Test your knowledge of creating database objects, including PRIMARY KEY and CHECK constraints in SQL. Learn how to specify constraints at the table and column levels.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser