Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

CREATE TABLE



The SQL CREATE TABLE Statement


The CREATE TABLE statement in SQL is used to create a new table in a database. It defines the structure of the table, including the column names, data types, constraints, and indexes.

Here's a basic example of how to use the CREATE TABLE statement:


CREATE TABLE TableName (
    Column1Name DataType1,
    Column2Name DataType2,
    ...
    CONSTRAINT ConstraintName CONSTRAINT_TYPE (ConstraintCondition),
    ...
);

      

Let's break down the components of the CREATE TABLE statement:

Here's a concrete example:


    CREATE TABLE Employees (
        EmployeeID INT PRIMARY KEY,
        FirstName VARCHAR(50),
        LastName VARCHAR(50),
        Age INT CHECK (Age >= 18),
        DepartmentID INT,
        FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID)
    );
   

In this example:

This CREATE TABLE statement creates a table named Employees with the specified columns and constraints.



Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java