Software Development Exam  >  Software Development Tests  >  Test: SQL Constraints - 1 - Software Development MCQ

Test: SQL Constraints - 1 - Software Development MCQ


Test Description

15 Questions MCQ Test - Test: SQL Constraints - 1

Test: SQL Constraints - 1 for Software Development 2024 is part of Software Development preparation. The Test: SQL Constraints - 1 questions and answers have been prepared according to the Software Development exam syllabus.The Test: SQL Constraints - 1 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: SQL Constraints - 1 below.
Solutions of Test: SQL Constraints - 1 questions in English are available as part of our course for Software Development & Test: SQL Constraints - 1 solutions in Hindi for Software Development course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: SQL Constraints - 1 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study for Software Development Exam | Download free PDF with solutions
Test: SQL Constraints - 1 - Question 1

Which of the following is not a type of integrity constraint in SQL?

Detailed Solution for Test: SQL Constraints - 1 - Question 1

In SQL, primary key, unique, and foreign key constraints are types of integrity constraints used to maintain data integrity. However, a "union constraint" is not a recognized type of constraint in SQL.

Test: SQL Constraints - 1 - Question 2

What is the purpose of a NOT NULL constraint in SQL?

Detailed Solution for Test: SQL Constraints - 1 - Question 2

The NOT NULL constraint in SQL ensures that a column cannot have a NULL value, i.e., it must have a non-null value.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: SQL Constraints - 1 - Question 3

Which of the following is true about a primary key constraint in SQL?

Detailed Solution for Test: SQL Constraints - 1 - Question 3

A primary key constraint in SQL ensures that the values in the specified column(s) uniquely identify each row in the table.

Test: SQL Constraints - 1 - Question 4

In SQL, which constraint is used to ensure that values in a column are unique across all rows in a table?

Detailed Solution for Test: SQL Constraints - 1 - Question 4

A unique constraint in SQL ensures that the values in the specified column(s) are unique across all rows in the table, i.e., no duplicate values are allowed.

Test: SQL Constraints - 1 - Question 5

Which of the following is an example of a referential integrity constraint in SQL?

Detailed Solution for Test: SQL Constraints - 1 - Question 5

A foreign key constraint in SQL is used to enforce referential integrity between two tables, ensuring that the values in the specified column(s) of one table match the values in the referenced column(s) of another table.

Test: SQL Constraints - 1 - Question 6

Consider the following SQL table definition:

CREATE TABLE Employees (
EmployeeID INT,
EmployeeName VARCHAR(50),
DepartmentID INT
);

Which of the following SQL statements adds a primary key constraint to the "EmployeeID" column?

Detailed Solution for Test: SQL Constraints - 1 - Question 6

The ALTER TABLE statement is used to modify an existing table. To add a primary key constraint to the "EmployeeID" column, the correct syntax is to use the CONSTRAINT keyword followed by the constraint name (e.g., PK_Employees) and the PRIMARY KEY keyword.

Test: SQL Constraints - 1 - Question 7

Consider the following SQL table definition:

CREATE TABLE Students (
StudentID INT PRIMARY KEY,
StudentName VARCHAR(50),
Age INT NOT NULL
);

Which of the following SQL statements adds a foreign key constraint to the "DepartmentID" column referencing the "Department" table?

Detailed Solution for Test: SQL Constraints - 1 - Question 7

The ALTER TABLE statement is used to modify an existing table. To add a foreign key constraint to the "DepartmentID" column, the correct syntax is to use the CONSTRAINT keyword followed by the constraint name (e.g., FK_Students_Department), the FOREIGN KEY keyword, and the REFERENCES keyword to specify the referenced table and column.

Test: SQL Constraints - 1 - Question 8

Consider the following SQL table definition:

CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
TotalAmount DECIMAL(10, 2)
);

Which of the following SQL statements adds a check constraint to the "TotalAmount" column to ensure that the value is greater than zero?

Detailed Solution for Test: SQL Constraints - 1 - Question 8

The ALTER TABLE statement is used to modify an existing table. To add a check constraint to the "TotalAmount" column, the correct syntax is to use the CONSTRAINT keyword followed by the constraint name (e.g., CHK_Orders_TotalAmount), the CHECK keyword, and the condition that should be satisfied for the constraint.

Test: SQL Constraints - 1 - Question 9

Consider the following SQL table definition:

CREATE TABLE Products (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(50) UNIQUE,
Price DECIMAL(10, 2) NOT NULL
);

Which of the following SQL statements alters the "Price" column to allow NULL values?

Detailed Solution for Test: SQL Constraints - 1 - Question 9

The ALTER TABLE statement is used to modify an existing table. To alter the "Price" column to allow NULL values, the correct syntax is to use the MODIFY COLUMN keywords followed by the column name (e.g., Price) and the NULL keyword.

Test: SQL Constraints - 1 - Question 10

Consider the following SQL table definition:

CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
CustomerName VARCHAR(50) NOT NULL,
Email VARCHAR(50) UNIQUE
);

Which of the following SQL statements drops the unique constraint on the "Email" column?

Detailed Solution for Test: SQL Constraints - 1 - Question 10

The ALTER TABLE statement is used to modify an existing table. To drop the unique constraint on the "Email" column, the correct syntax is to use the DROP CONSTRAINT keyword followed by the constraint name (e.g., UQ_Customers_Email).

Test: SQL Constraints - 1 - Question 11

Consider the following SQL table definition:

CREATE TABLE Books (
BookID INT PRIMARY KEY,
BookName VARCHAR(50),
AuthorID INT,
FOREIGN KEY (AuthorID) REFERENCES Authors(AuthorID) ON DELETE CASCADE
);

Which of the following constraints is specified in the table definition?

Detailed Solution for Test: SQL Constraints - 1 - Question 11

In the given table definition, the "FOREIGN KEY" constraint is specified for the "AuthorID" column, which references the "Authors" table. This constraint ensures the referential integrity between the "Books" and "Authors" tables.

Test: SQL Constraints - 1 - Question 12

Consider the following SQL table definition:

CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
EmployeeName VARCHAR(50),
ManagerID INT,
CONSTRAINT FK_Employees_Manager FOREIGN KEY (ManagerID) REFERENCES Employees(EmployeeID)
);

Which type of relationship is represented by the foreign key constraint in the "Employees" table?

Detailed Solution for Test: SQL Constraints - 1 - Question 12

The foreign key constraint in the "Employees" table references the "EmployeeID" column in the same table. This represents a "Many-to-One" relationship, as multiple employees can have the same manager.

Test: SQL Constraints - 1 - Question 13

Consider the following SQL table definition:

CREATE TABLE Products (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(50),
CategoryID INT,
CONSTRAINT CHK_Products_Category CHECK (CategoryID IN (1, 2, 3))
);

Which of the following constraints restricts the possible values of the "CategoryID" column to a specific set of values?

Detailed Solution for Test: SQL Constraints - 1 - Question 13

The "CHECK" constraint specified in the table definition restricts the possible values of the "CategoryID" column to a specific set of values (1, 2, 3).

Test: SQL Constraints - 1 - Question 14

Consider the following SQL table definition:

CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
EmployeeName VARCHAR(50),
DepartmentID INT
);

Which of the following SQL statements adds a foreign key constraint to the "DepartmentID" column referencing the "Departments" table, where the "DepartmentID" column in the "Departments" table is defined as UNIQUE?

Detailed Solution for Test: SQL Constraints - 1 - Question 14

To add a foreign key constraint to the "DepartmentID" column in the "Employees" table, referencing the "Departments" table where the "DepartmentID" column is defined as UNIQUE, the correct syntax is to use the CONSTRAINT keyword followed by the constraint name (e.g., FK_Employees_Departments), the FOREIGN KEY keyword, and the REFERENCES keyword specifying the referenced table and column.

Test: SQL Constraints - 1 - Question 15

Consider the following SQL table definition:

CREATE TABLE Students (
StudentID INT PRIMARY KEY,
StudentName VARCHAR(50),
Age INT
);

Which of the following SQL statements adds a unique constraint to the "StudentName" column?

Detailed Solution for Test: SQL Constraints - 1 - Question 15

To add a unique constraint to the "StudentName" column in the "Students" table, the correct syntax is to use the CONSTRAINT keyword followed by the constraint name (e.g., UQ_Students_StudentName), the UNIQUE keyword, and the column name (e.g., StudentName).

Information about Test: SQL Constraints - 1 Page
In this test you can find the Exam questions for Test: SQL Constraints - 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: SQL Constraints - 1, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

Download as PDF

Top Courses for Software Development