SQL PRIMARY KEY and CHECK Constraints
27 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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

  • To enforce referential integrity between tables
  • To create a unique index on a column
  • To specify the primary key of a table
  • To define a default value for a column when no value is specified (correct)

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

  • A stored procedure or a function
  • A constant, a built-in function, or a mathematical expression (correct)
  • A SELECT statement or a subquery
  • Only a constant value

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 (correct)
  • At the end of the CREATE TABLE statement, after the definition of all columns
  • In the ALTER TABLE statement, when modifying the column
  • In a separate statement, after the CREATE TABLE statement

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

<p>The database engine assigns an implicit name for the default (A)</p> Signup and view all the answers

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

<p>To assign a name to the default constraint (D)</p> Signup and view all the answers

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

<p>Yes, and the default value is ignored if a value is specified during an INSERT operation (A)</p> Signup and view all the answers

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

<p>The specified value is used, and the default value is ignored (A)</p> Signup and view all the answers

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

<p>Yes, and the default value is ignored if a value is specified during an INSERT operation (C)</p> Signup and view all the answers

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

<p>It simplifies data entry by providing a default value when no value is specified (D)</p> Signup and view all the answers

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

<p>To allow efficient access to data stored on a disk (C)</p> Signup and view all the answers

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

<p>View (B)</p> Signup and view all the answers

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

<p>To create a relationship between the employee and project tables (D)</p> Signup and view all the answers

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

<p>The related row in works_on1 is deleted (C)</p> Signup and view all the answers

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

<p>To execute a sequence of statements written in Transact-SQL (C)</p> Signup and view all the answers

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

<p>The related row in works_on1 is updated (D)</p> Signup and view all the answers

What are the two types of database objects?

<p>Physical and Logical (C)</p> Signup and view all the answers

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

<p>Database (D)</p> Signup and view all the answers

What type of databases can an authorized user create?

<p>User databases (A)</p> Signup and view all the answers

What is managed by the Database Engine?

<p>Both system and user databases (B)</p> Signup and view all the answers

What is an example of a logical object?

<p>Table (D)</p> Signup and view all the answers

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

<p>tempdb, model, and msdb (D)</p> Signup and view all the answers

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

<p>128 characters (B)</p> Signup and view all the answers

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

<p>To specify the first file that contains system tables and other important internal information (D)</p> Signup and view all the answers

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

<p>10MB (B)</p> Signup and view all the answers

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

<p>Using Object Explorer (B)</p> Signup and view all the answers

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

<p>projects.ldf (C)</p> Signup and view all the answers

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

<p>5MB (A)</p> Signup and view all the answers

More Like This

SQL Basics Quiz
10 questions

SQL Basics Quiz

HaleRetinalite2094 avatar
HaleRetinalite2094
ClassicModels SQL Exercises
26 questions
Use Quizgecko on...
Browser
Browser