Some basic syntax for MySQL

Source: Internet
Author: User

Use + database name: using this database


Creating a data table unsgined means unsigned bit
[IF not EXISTS] can be omitted
CREATE table [IF not EXISTS] table (

Usename VARCHAR (20),
Age TINYINT unsgined

)

Show TABLES: See how many tables there are in the database
Show TABLES from MySQL: View tables for all databases
SELECT database (): Displays the current database
Show COLUMNS from SS: View the structure type of the database
Inserting data into a table
INSERT SS (Name,age) VALUES (' Li Haiyang ', 20)

Auto_increment: Auto-numbered and must be combined with primary key
By default, its starting value is 1, with increments of 1 per

Specifies that the text column be placed first
ALTER TABLE AA Modify text VARCHAR (255) First

Put the text behind age
ALTER TABLE AA Modify text VARCHAR (255) after age


Where: It is followed by the condition of the query.

As N uses aliases.

Delete data from Name= Li Haiyang in the SS table
DELETE from SS WHERE name= ' Li Haiyang '
Delete ID this column
ALTER TABLE SS DROP COLUMN ID;

Add an ID to this column
ALTER TABLE SS add column ID INT PRIMARY KEY auto_increment

Some basic syntax for MySQL

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.