MySQL Basic operation

Source: Internet
Author: User

I use the operating system when the Ubuntu16.04, the operation is implemented on the command line:

Start MySQL service: sudo service MySQL start

Log in as root: Mysql-u root-p

Display database: show databases;

Connection database: Use database name;

Creating database: Create database name;

Creating Tables: Create table table name (column name a data type (length), column name B data type (length), column name C data type (length));

Show table: Show tables; (You cannot use this statement to display table name information in a specified database until you connect to the database)

Add data to table: INSERT into table name (column name A, column name B, column name C) VALUES (value 1, value 2, value 3);

View the contents of the table: SELECT * from table name; (See the table for details)

Data type size (bytes) purpose format
int 4 integer
Float 4 single-precision floating-point number
Double 8-precision floating-point number
Enum radio, such as Gender enum (' A ', ' B ', ' C ')
Set multi-select Set (' 1 ', ' 2 ', ' 3 ')
Date 3rd period Yyy-mm-dd
Time 3 point or Duration HH:MM:SS
Year 1 servings value yyyy
CHAR 0~255 Fixed-length string
VARCHAR 0~255 Variable length string
Text 0~65535 Long Text data

Single quotes are generally required for enum, date, time, char, and text data.

MySQL Basic operation

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.