What is table?
The table is a collection of related data entries and columns and rows.The data in SQL is stored in database tables.
The CREATE TABLE statement is used to create a table in a database.
Syntax:
The data type specifies what type of data the column can hold.
Examples:
Output:
Create Tables using the MS-SQL Server:
Step 1:Select "New Table"
Step 2:Next, the table designer pops up where you can add columns, data types and etc.
Step 3: Save the table by clicking the "Ctrl-S"
The table is a collection of related data entries and columns and rows.The data in SQL is stored in database tables.
The CREATE TABLE statement is used to create a table in a database.
Syntax:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
The data type specifies what type of data the column can hold.
Examples:
- Numbers: int, float
- Text/Stings: varchar(X) – where X is the length of the string
- Dates: datetime
- etc.
CREATE TABLE CANDIDATE
(
CandidateId int IDENTITY(1,1) PRIMARY KEY,
CandidateNumber int NOT NULL UNIQUE,
LastName varchar(50) NOT NULL,
FirstName varchar(50) NOT NULL,
PostCode int NULL,
Address varchar(50) NULL,
Phone varchar(50) NULL,
)
(
CandidateId int IDENTITY(1,1) PRIMARY KEY,
CandidateNumber int NOT NULL UNIQUE,
LastName varchar(50) NOT NULL,
FirstName varchar(50) NOT NULL,
PostCode int NULL,
Address varchar(50) NULL,
Phone varchar(50) NULL,
)
Output:
Create Tables using the MS-SQL Server:
Step 1:Select "New Table"
Step 2:Next, the table designer pops up where you can add columns, data types and etc.
Step 3: Save the table by clicking the "Ctrl-S"
Post a Comment