codesnout.com

SQL CREATE TABLE

Google Ads

SQL CREATE TABLE


SQL Sample Code - SQL CREATE TABLE Statement

The statement below creates a database table. You must have created a database before creating a table. See SQL CREATE DATABASE to learn how to do this.

CREATE TABLE table_name
(
column_name1 column1_data_type,
column_name2 column2_data_type,
column_name3 column3_data_type,
column_name4 column4_data_type,
....
);

See the SQL samples section below for an explanation of the CREATE TABLE statement.


What does the SQL CREATE TABLE Statement do?

The SQL CREATE TABLE statement creates a table within a database.


Sample – SQL CREATE TABLE

In this SQL sample we will create a table called ‘tblCompany’ with 3 columns; Company_ID, Company_Name and Sales.

Use the CREATE TABLE statement below:

CREATE TABLE tblCompany
(Company_ID int
CompanyName varchar(255)
Sales int);

The table will look like this:.

Company_ID CompanyName Sales
     

The ‘int’, ‘varchar(255)’ elements of the statement are the data types. To learn more about these and more go to the Data Type sections of this website.

Data-Type Description (MySQL)
int (Integer) A normal-size integer. The signed range is -2147483648 to 2147483647.
varchar Character String Value. The length can be specified as a value from 0 to 65,535.

 


Related SQL Sample Code:


About Us | Privacy Policy | Contact Us | ©2010 Thunderousity Information Management Solutions | www.autosnout.com - Car Performance Statistics Website Utilising SQL | SQL Blog |

SQL Home | SQL Intro | SQL SELECT Statement | DISTINCT | WHERE | SQL Wildcards | AND OR | IN | BETWEEN | LIKE | ORDER BY | GROUP BY | TOP | ALIAS | DELETE | INSERT | UPDATE | CREATE DATABASE | CREATE TABLE | ALTER | INNER JOIN | FULL JOIN | LEFT JOIN | RIGHT JOIN | UNION | CONSTRAINTS | NOT NULL| Aggregate Functions | SUM | AVG | COUNT | MAX | MIN | FIRST | LAST | GROUP BY | HAVING | LIMIT | Microsoft Access Data Types | MySQL Data Types | SQL Server Data Types | ASCII HTML Reference Sheet |