MySQL Basic operation

Source: Internet
Author: User

Display database:show databases;

Use database (Connect database to switch database):use+ database name;

Show a table in a database:show tables;

Creating database: Createdatabase+ database name;

To create a table:

CREATE TABLE Student (

ID int (4) primary key auto_increment,

Name varchar (one) not NULL comment " name ",

Number varchar (one) not NULL comment " Study no. "

);

(Manipulate table content data)

Query all data in a table:select * from table name;

Select Name,number from table name;

Insert a piece of data into a table:insert into table name VALUES ( attribute values );

INSERT into table name (name,number) VALUES (' SDF ', ' sdfgh ');

Delete a record in a table:delete from table name where property = a value ;

Modify a record in a table:update table name set property = A value where Properties = a certain value;

(Manipulate table properties)

Show Table Structure Properties : desc+ table name;

Add a property to a table:alter table name Add property name data type, etc.;

Delete a property of a table:alter table name drop property name;

Modifies a property of a table:alter table name Changes the property name data type after the original property name is modified;

Data type : range based on experience

Datatime type is a time format

tinyint (4); represents a number;

Modify the name of the database table:rename table name to the present form name;

See if the changes were successful: show tables;

Delete database table:drop table name;

Delete the database:drop database name;

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.