MySQL Data Type and creation, mysql Data Type Creation

Source: Internet
Author: User

MySQL Data Type and creation, mysql Data Type Creation

MySQL creation:

1. Create a database
Create database test2;
2. delete a database
Drop database test2;

3. Create a table
Create table ceshi
(
Ids int auto_increment primary key,
Uid varchar (20 ),
Name varchar (20 ),
Class varchar (20 ),
Foreign key (class) references class (code)
);
Create table class
(
Code varchar (20) primary key,
Name varchar (20) not null
);

** Auto-increment auto_increment
** Primary key
** Foreign key (column name) references main table name (column name)
** Non-null not null

4. delete a table
Drop table ceshi;

Note:
1. If the type contains the length, brackets are added after the type, and the length is written in brackets.
2. Add a comma (,) to the last column.
3. Do not enter a comma in the last column.
4. Add points after each SQL statement is written
5. If there is a foreign key relationship, first create a master table

Data Types in MySQL

MySQL has three types of data: numbers, dates, times, and strings, which are further divided into multiple subtypes:

  • Numeric type
    • Integer: tinyint, smallint, mediumint, int, bigint
    • Floating Point: float, double, real, decimal
  • Date and Time: Date, time, datetime, timestamp, year
  • String type
    • String: char, varchar
    • Text: tinytext, text, mediumtext, longtext
    • Binary (used to store images and music): tinyblob, blob, mediumblob, and longblob

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.