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</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</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</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</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</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</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</p> Signup and view all the answers

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

    <p>View</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</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</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</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</p> Signup and view all the answers

    What are the two types of database objects?

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

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

    <p>Database</p> Signup and view all the answers

    What type of databases can an authorized user create?

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

    What is managed by the Database Engine?

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

    What is an example of a logical object?

    <p>Table</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</p> Signup and view all the answers

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

    <p>128 characters</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</p> Signup and view all the answers

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

    <p>10MB</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</p> Signup and view all the answers

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

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

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

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

    More Like This

    Introduction to SQL Database Model
    10 questions
    ClassicModels SQL Exercises
    26 questions
    Use Quizgecko on...
    Browser
    Browser