Review the--mysql base statement

Source: Internet
Author: User

1. Database ("Pikachu" Here is the database name)

SHOW DATABASES; # #查看数据库

Use Pikachu; # #切换到数据库
CREATE DATABASE Pikachu; #创建数据库

DROP DATABASE Pikachu; #删除数据库


2. table ("Student" here is the table name)

SHOW TABLES; #查看表
CREATE TABLE Student (name VARCHAR), sex CHAR (1)); # #创建表

DROP TABLE student; # #从数据库中删除表

       describe   student;                        # #查看表结构
        INSERT   into    student   VALUES (' Lmy ', ' F ');                       # # Add information to the table  

DELETE from student WHERE attribute = value; # #从表中删除信息
SELECT * from student; # #查看表中所有信息
UPDATE student SET attribute=value2 WHERE attribute > =value1; # #修改表中信息, change the value1 in the table to value2

ALTER TABLE Student Add age varchar (4); # #向表中添加 "Age" field

ALTER TABLE student DROP age; # #从表中删除字段


3. Enquiry

SELECT * from Pikachu.student; # #查询pikachu数据库下的student表

SELECT name from student WHERE age= ' and sex= ' M '; # #查询student表中年龄为20, sex man's name

4. Refreshing the database Information

FLUSH privileges;

5.mysql root user password forgot solution





This article from "11849650" blog, declined reprint!

Review the--mysql base statement

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.