The basic operation of the road MySQL database and learning data table 2-

The basic database operations

View, select Database: show databases; use <databasename>;

Create database: Create Database <dbname> Character SET <encoding format> ; Character encoding format specified in accordance with the SET

Delete the database: drop database <dbname>;

 

Basic Operation Data Sheet

View Table: show tables

See table structure: describe <tablename>;

See data in Table: SELECT * from <TableName> limit <number> ;

 

Built table: create table <tablename> (<field name> <type: int unsigned primary key not null>,

Field name> <type>);

Insert a record in the table: insert into <tablename> (1 field names, field names 2)

       values ​​(the value of the field 1, field value of 2),

                (1 field value, the field value of 2);

Delete the table:

drop table <tablename>;

 

Modify the data sheet:

  • Adding fields alter table <tablename> add <added field name> <field type> After <field name> ; After the specified location in the field increases
  • Delete field alter table <tablename> drop <Delete field name>;
  • 表重命名 alter table <tablename> rename <newtablename>; 
  • Field Rename alter table <tablename> change <field name> <new field name> <field type>;
  • Delete records in the table delete from <tablename> where <query>;
  • Modify records in the table update <tablename> set <content: stuname = 'Jack'> where <query: stuid = '20160101'>;

2020-03-09 20:41

Guess you like

Origin www.cnblogs.com/fuyusheng/p/12450903.html