Computer Science · SQL Constraints
A university administrator wants to ensure that every course has a unique course code in the Courses table and prevent any course record from being created without specifying the course name. Which SQL statement ensures these constraints during table creation?
- 1CREATE TABLE Courses (CourseCode INT, CourseName VARCHAR(50));
- 2CREATE TABLE Courses (CourseCode INT PRIMARY KEY, CourseName VARCHAR(50) NOT NULL);✓
- 3ALTER TABLE Courses ADD CourseCode UNIQUE;
- 4INSERT INTO Courses VALUES ('Null', 'Course');
Correct answer
CREATE TABLE Courses (CourseCode INT PRIMARY KEY, CourseName VARCHAR(50) NOT NULL);
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on SQL Constraints?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · SQL Constraints