The most basic SQL statement

1. Folder (library)

    Add: create database db1 charset utf8;
    change: alter database db1 charset gbk;
    check:
        check the database names of all databases
        show databases;
        check the information of a certain database separately
        show create database db1;

    

    删:drop database db1;



2. Documents (tables)

    First switch the folder:
        use db1;
        select database(); #View the current folder and
    add
        create table t1(id int,name char);
    Change

        alter table t1 modify name char(16);

       Modify the table name: alter table old table name rename to new table name;

        Modify the field name in the table: alter table table name change old field new field type;

    View
        all table names under the current database
        show tables;
        view the details of the t1 table
        show create table t1;
        view the table structure
        desc t1;

    delete
        drop table t1;

3. One line of the file (record)

    增
        insert into db1.t1 values
        (1,'monicx'),
        (2,'wss');
    改
        update db1.t1 set name='sb' where id =2;
    查
        select id,name from db1.t1;
    删
        delete from db1.t1 where name = "wmm" ;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325749296&siteId=291194637