MySQL basic command

Source: Internet
Author: User

MySQL basic command
  • SQL features

    DML(数据操作语言):用于检索或修改数据。DDL(数据定义语言):用于定义数据的结构,如创建、修改或者删除数据库对象。DCL(数据控制语言):用于定义数据库用户的权限。
  • View Database

    show databases;
  • Working with databases

    use test1;
  • View tables in the database

    show tables;
  • View table Structure

    desc people;
  • Database creation Scripts

    create table people(id         INT           AUTO_INCREMENT PRIMARY KEY,name       VARCHAR(30)   NOT NULL,password   VARCHAR(30)   NOT NULL,age        INT           NOT NULL,sex        VARCHAR(2)    DEFAULT‘男‘,birthday   date);
  • Add data

    insert into people (name,password,age,sex,birthday) values (‘zhangsan‘,‘1997‘,21,‘男‘,‘2005-02-02‘);
  • Delete data

    delete from people where name=‘zhangsan‘;
  • Querying data

    select * from people;select age from people where name=‘zhangsan‘;
  • modifying data

    update people set age=36 where name=‘zhangsan‘;

Reference Tutorials

After the basic operation, there will be many problems in the actual operation.
    1. When a table is built, the last line does not need a comma (,), which is why I have been bothering for a long time.
    2. Inserting Chinese characters is not allowed when inserting data, because the database does not have coding reasons. Reference URL
    3. Input always avoid unavoidable input errors, but sometimes input exit or quit and so on, the way is that some of the commands are in pairs appear, input error when the other half to fill on it. Reference URL
    4. The cmd window is not easy to use with a panel window, but the command line can be greatly improved. After entering the command line, if you prompt the error, look at the error prompt, it is generally a good solution. You can see the picture below for details.

MySQL basic command

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.