Try the Introductory SQL Course for Free!

CREATE TABLE Statement in SQL- Tutorial and Syntax

/ / Latest, SQL

The CREATE TABLE Statement in SQL: Overview

            One of the most commonly used SQL statements when creating a database is the CREATE TABLE statement, which is used to create tables within a database. The general syntax of the CREATE TABLE statement is shown below.

CREATE TABLE table_name

(

field_name data_type(size),

field_name1 data_type(size),

field_name2 data_type(size),

etc.

)

            The “table_name” parameter is the name you want to assign to the table. The “field_name” parameters are the names of the fields, or columns, within the table. The “data_type” parameter is the declaration of the data type of each field. Each vendor will have vendor-specific names for the data types available. You should check the documentation for the database management system you are using to determine the specific name of each data type available. For example, in Microsoft Access, a text field with a 255 character limit is declared by the “TEXT” data type, but the same type of field is declared by the “TINYTEXT” data type within MySQL. The “size” parameter, if needed for the “data_type” selected, will define the number of characters to store within the field.

            While the CREATE TABLE statement, shown above, is the core SQL standard, you will find that the statement tends to be more complex within the actual vendor implementations. Below is a listing of hyperlinks that display the SQL used to implement the CREATE TABLE statement within MySQL 5.7, SQL Server 2012, and Access 2013.

MySQL 5.7:

https://dev.mysql.com/doc/refman/5.7/en/create-table.html

SQL Server 2012:

https://technet.microsoft.com/en-us/library/ms174979.aspx

Access 2013:

https://msdn.microsoft.com/en-us/library/office/ff837200.aspx

The CREATE TABLE Statement in SQL- Tutorial: A picture of the "Mastering Introductory SQL Made Easy v.1.0" interface.

The CREATE TABLE Statement in SQL- Tutorial: A picture of the “Mastering Introductory SQL Made Easy v.1.0” interface.

The CREATE TABLE Statement in SQL: General Syntax

CREATE TABLE table_name

(

field_name1 data_type(size),

field_name2 data_type(size),

field_name3 data_type(size),

)

The CREATE TABLE Statement in SQL: Video Lesson

            The following video lesson, titled “2.3- The CREATE TABLE Statement,” discusses the general syntax of the CREATE TABLE statement in SQL and then demonstrates using the statement in Access 2013. This is from our complete Introductory SQL tutorial, titled “Mastering Introductory SQL Made Easy v.1.0.”

TOP
Sale! $49 All-Access 0 Days 12 Hours 44 Minutes 20 Seconds      $199 $49 Entire Library!
See Deal