Skip to main content

NOT NULL in SQL

NOT NULL constraints:
                                        The NOT NULL constraints restricts null value in database table.
Syntax:
                CREATE TABLE Employee(id int, emp_name nvarchar(18) NOT NULL);
This statement create table employee, in that emp_name should not be null value.
DESC Employee
Desc statement describe the table. 
 Field Data Type Null key Default
 id INT NO  
 emp_name NVARCHAR(18) NO  

               CREATE TABLE Course(id int NOT NULL, Course_name nvarchar(20));
Desc Course (in Oracle) 
 Field Data Type Null key Default
 id INT NO  
Course_name NVARCHAR(20) NO  

Using Alter to Set NOT NULL:
ALTER TABLE course ALTER COLUMN Course_name nvarchar(20) NOT NULL; in MSSQL server.

ALTER TABLE Course MODIFY Course_name  nvarchar(20) NOT NULL; in ORACLE.

ALTER TABLE Course MODIFY COLUMN Course_name nvarchar(20) NOT NULL; in MSACCESS.

Desc Course.
 Field Data Type Null key Default
 id INT NO  
Course_name NVARCHAR(20) NO  




Thank You. Like, Share and Subscribe 👍 Followlect.com

Comments