SQL getting started Tutorial: SQL create table and database [create databse]

Source: Internet
Author: User

SQL getting started Tutorial: SQL create table and database [create databse]

The statement for creating a database
The create database statement is used to CREATE a DATABASE.

SQL syntax for creating a database

Create database database_name
The example of creating a database is now that we need to create a database called "my_db ". We use the following create database statement: create database my_db
 
Next let's take a look at the SQL statement used to create a table
The create table declaration is used to create a table in the database. Create table table_name
(
Column_name1 data_type,
Column_name2 data_type,
Column_name3 data_type,
....
)
The data type specifies the type of data columns that can be shelved. For MS Access, MySQL, and SQL Server provided by a complete reference for all data types, please give us a complete data type reference. Now we want to create a table named "person", which contains five columns: P_Id, last name, name, address, and city. Create table Persons
(
P_Id int,
LastName varchar (255 ),
FirstName varchar (255 ),
Address varchar (255 ),
City varchar (255)
)
 
The P_Id column is of the int type and is held some. The maximum length of the last name, name, address, and city column varchar is 255 characters. The blank "person" looks like this: _ Id LastName FirstName Address City

Related Article

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.