Add NOT NULL and DEFAULT to a column

Add NOT NULL and DEFAULT to a column

Easy SQL Constraints 17 views
Explanation Complexity

Problem Statement

You have a table Employees(emp_id, name, dept_id, salary, hire_date). Make dept_id mandatory and set default salary as 30000 for new rows.

Input Format

SQL DDL

Output Format

DDL statement(s)

Example

Employees(emp_id, name, dept_id, salary, hire_date)
Altered table

Constraints

Use generic SQL

Input / Output Format

Input Format
SQL DDL
Output Format
DDL statement(s)
Constraints
Use generic SQL

Examples

Input:
Employees(emp_id, name, dept_id, salary, hire_date)
Output:
Altered table

Example Solution (Public)

SQL
ALTER TABLE Employees ALTER COLUMN dept_id SET NOT NULL; ALTER TABLE Employees ALTER COLUMN salary SET DEFAULT 30000;

Official Solution Code

ALTER TABLE Employees ALTER COLUMN dept_id SET NOT NULL; ALTER TABLE Employees ALTER COLUMN salary SET DEFAULT 30000;
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.