A concise tutorial of SQL statements for Linux---CREATE TABLE

Source: Internet
Author: User

Tables are the basic framework for storing data in a database. In most cases, it is not possible for a database vendor to know how you need to store your data, so you will usually need to create a table in your database. Although many database tools allow you to create tables without the need for SQL, we decided to include the syntax for CREATE TABLE in this site because the table is the most basic schema.

Before we jump into the syntax of CREATE table , we'd better get a little more information on the table. The table is divided into columns (column) and yours faithfully (row). Each column represents a single piece of information, each of which represents a portion of the information. For example, if we have a table that records customer data, that field may include a surname, name, address, city, country, birthday ... Wait a minute. When we define the table, we need to indicate the title of the field and the type of information in that field.

So, what is the type of data? The information may exist in many different forms. It can be an integer (for example, 1), a real number (for example, 0.55), a string (such as ' SQL '), a date/time (such as ' 2000-jan-25 03:22:22 '), or even a binary (binary) state exists. When we define a table, we need to define the type of data for each field. (for example, ' Last name ' This field is the type of char (50) ━━ represents a 50-character string). One thing we need to be aware of is that different databases have different data types, so it's a good idea to refer to the database itself before making a definition of the table.

The syntax for CREATE TABLE is:

CREATE table "table name"
("Field 1" "Field 1 data Type",
"Field 2" "Field 2 data Type",
... );

If we want to create the customer form we mentioned above, we will enter the following SQL:

CREATE TABLE Customer
(First_Name char (50),
Last_Name Char (50),
Address Char (50),
City Char (50),
Country char (25),
Birth_date datetime);


Linux is measured as follows:





Reprint please specify: Xiao Liu



A concise tutorial of SQL statements for Linux---CREATE TABLE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.