How to create table in SQL?

To create table in SQL you have to use following syntax

CREATE TABLE table_name (
column_1 datatype,
column_2 datatype,
column_3 datatype
);

It’s important to place comma after each column definition, and semicolon after whole stat…


This content originally appeared on DEV Community and was authored by Damian Brdej

To create table in SQL you have to use following syntax

CREATE TABLE table_name (
    column_1 datatype,
    column_2 datatype,
    column_3 datatype
);

It's important to place comma after each column definition, and semicolon after whole statement.

Here's real life example:

CREATE TABLE users (
    id INT,
    name VARCHAR(255),
    surname VARCHAR(255),
    email VARCHAR(255),
    password VARCHAR(255)
);

This statement creates table with 4 columns. First one is of type INT which means integer value. The other 4 columns are of type VARCHAR(255) which means TEXT with maximum length of 255. You can place any number in brackets to define length.


This content originally appeared on DEV Community and was authored by Damian Brdej


Print Share Comment Cite Upload Translate Updates
APA

Damian Brdej | Sciencx (2021-07-05T17:06:17+00:00) How to create table in SQL?. Retrieved from https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/

MLA
" » How to create table in SQL?." Damian Brdej | Sciencx - Monday July 5, 2021, https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/
HARVARD
Damian Brdej | Sciencx Monday July 5, 2021 » How to create table in SQL?., viewed ,<https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/>
VANCOUVER
Damian Brdej | Sciencx - » How to create table in SQL?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/
CHICAGO
" » How to create table in SQL?." Damian Brdej | Sciencx - Accessed . https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/
IEEE
" » How to create table in SQL?." Damian Brdej | Sciencx [Online]. Available: https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/. [Accessed: ]
rf:citation
» How to create table in SQL? | Damian Brdej | Sciencx | https://www.scien.cx/2021/07/05/how-to-create-table-in-sql/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.