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