MySQL Basic statement

Source: Internet
Author: User

Mysql-u root-p;

Log in to Database

show databases;

Presentation Database

Show tables;

Display table

DESC messages;

View the structure of the messages table

Drop database lovestory;

Delete Lovestory Database

CREATE TABLE messages (

ID int primary KEY auto_increment,

Name varchar (50),

Article text,

Created_at Timestamp

) Engine=innodb;

Create a messages table

(The InnoDB type supports transactions.) MySQL defaults to the MyISAM engine, which does not support transactions and only stores data, with the advantage of reading and writing very quickly. )

ALTER TABLE photo rename photos;

Modify Table Name

ALTER TABLE messages modify article text;

modifying field data types

(article: Field name, Text: the type to be modified)

ALTER TABLE messages change article myarticle;

Modify field names

ALTER TABLE messages add UPDATE_AT timestamp;

Add Field

ALTER TABLE messages drop UPDATE_AT;

Delete a field

drop table messages;

Delete a table

SELECT * from messages;

Querying all data in a table

Select name from messages where id=1;

Name of the data in the query table with ID 1

Select COUNT (*) from messages where name= ' Zhangsan ';

Number of data bars in the query table with name Zhangsan

INSERT into messages values (1, ' Joyce ', ' hehe ', ' 2014-12-13 21:56:03 ');

INSERT into messages (Name,text) VALUES (' Joyce ', ' Heheda ');

Inserting data

Update messages Set name= ' qsq ', article= ' hehe ' where id=1;

Update data

Delete from messages where id=1;

Delete data

MySQL Basic statement

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.