SQL most important statement

Query the current database version: select version();

Query the current database user: select user();

Query the current path: select @@basedir;

Query all databases: show databases;

Choose a database: use + database name;

Query the current database: select database();

Query all table names: show tables;

Create a database: create database database name;

Delete a database: drop database database name;

Query the structure of a table: desc table name;

Create student table (id, name, age, sex, birthday) under the class database
create table student(id int,name varchar(20), age int, sex varchar(20), birthday int);

(1) Specify all field names in the INSERT statement.
Syntax: INSERT INTO table name (field name 1, field name 2, ...) VALUES (value 1, value 2, ...);
Example: Insert (id Is 1, name: xiaoqiao, age: 18, gender: woman, birthday: 2002) data.
insert into student(id,name,age,sex,birthday) values(1,"xaoqiao",18,"woman","2002");

(2) The field name is not specified in the INSERT statement.
Syntax: INSERT INTO table name VALUES (value 11, value 2, ...);
example: insert into the student table under the database class (id is 2, name: daqiao, age: 20, Gender: woman, birthday: 2004) data.
insert into student values(2,"daqiao",20,"woman","2000");

Guess you like

Origin blog.csdn.net/Daoke37/article/details/114918083