Create a data table in MySQL and add data
1. Create table
create table test_table(
ID int,
Ename varchar(255),
job varchar(255),
job_num int );
2. Add values to the table
insert into t_user(key 1, key 2, key 3...) values(value 1, value 2, value 3...);//When the value is a string, quotes '' are required, such as 'zhangsan'.
For example, insert into t_user(id,name) values(1,'zhangsan');
insert into t_user(id,name) values(2,'wang_wu');
Note: When running the above statement of mysql in the cmd window, the last Add commit to submit the above data operations.
3. Supplement:
There is a problem when using python's MysqlDB package to insert Mysql, the program runs without error, and the insert statement is no problem, but the new data has not been inserted into the database. After consulting the information, it was found that it was not submitted.
There are four types of database languages,
Data Manipulation Language (Date Manipulation Language) DML language, realizes the basic operation of data, "addition, deletion and modification".
UPDATE DELETE INSERT
Data Definition Language (Data Definition Language) DDL language can realize the definition of database structure, operation method, etc.:
create table create table
alter table modify table
drop table delete table
truncate table deletes all rows in the table
create index create index
drop index drop index**
Database Control Language (Data Control Language) DCL authorization, role control
GRANT Authorization
REVOKE deauthorize
Transaction Control Language Transaction Control Language
SAVEPOINT set savepoint
ROLLBACK rollback
SET TRANSACTION
Among them, the DDL statement has its own commit, and if the DML command is not submitted, it will not be seen by other sessions. Unless the DDL command or DCL command is executed after the DML command, or the user exits the session or terminates the instance, the system will automatically issue the commit command to make the uncommitted DML command commit.
It is recommended to submit (commit) every time you modify or insert data into a table in MYSQL!