Tuesday, January 14, 2025
HomeComputer ScienceWhat is the Function of SQL CREATE TABLE Statement?

What is the Function of SQL CREATE TABLE Statement?

The CREATE TABLE statement in SQL is used to define a new table in a database. It specifies the table name and the columns it will contain, along with the data types for each column. The basic syntax is:

CREATE TABLE table_name (
column1 datatype [constraints],
column2 datatype [constraints],

);

See also  Types of Computers

table_name: The name of the table to be created.

column1, column2, …: The names of the columns in the table.

datatype: The data type for each column (e.g., INT, VARCHAR, DATE).

constraints: Optional rules like PRIMARY KEY, NOT NULL, UNIQUE, etc., that enforce integrity.

See also  What is Google Cloud Platform (GCP)?

Example:

CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
Name VARCHAR(100),
HireDate DATE
);

This creates an “Employees” table with three columns: EmployeeID, Name, and HireDate.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x