SQL Server Tutorial
A table is a database object used to store data and table is combination of rows and columns. Each row in a table denotes a unique record and each column denotes an attribute of the record.
Column names within a table must be unique but same column name can be used in different tables within a database.
CREATE TABLE Statement is used to create a table in the database.
CREATE TABLE table_name ( column_name datatype [NULL | NOT NULL] [IDENTITY (SEED, INCREMENT)], column_name datatype .... )
NULL | NOT NULL are keywords that specify whether or not NULL values are allowed.
IDENTITY is used for those columns that need automatically generated unique system values and can be used to generate sequential numbers.
SEED is the starting or the initial value for the IDENTITY column.
INCREMENT is the step value used to generate the next value for the column. This value can also be negative.
CREATE TABLE Department ( Id int NOT NULL, Name varchar(25) NOT NULL, Head varchar(25) )Output:
Command(s) completed successfully.
CREATE TABLE Employee ( Id int IDENTITY(1,1), Name varchar(25) NOT NULL, DeptId int NOT NULL, Email varchar(25) NULL )Output:
Command(s) completed successfully.
CREATE TABLE Employee ( Id int IDENTITY(1,1), Name varchar(25) NOT NULL, DeptId int NULL, Email varchar(25) NULL, Salary int NOT NULL, City varchar(20), Country varchar(20) )
Command(s) completed successfully.
DROP Statement is used to remove the table in the database.
DROP TABLE <TABLE NAME>
DROP TABLE Employee
SQL Server Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page