A common method: INSERT into table name (Id,name,age,status, field N) VALUES (' id ', ' name ', ' age ', ' status ', ' field n '); --Suggest using this
Insert into table name values (column values);
Example: INSERT into User (Id,name,age,status,role) VALUES (' 1 ', ' xiaoming ', 23, 1, ' Group master ');
or insert into user values (' 1 ', ' xiaoming ', 23, 1, ' Group master ');
Second, from the table query convenient method: INSERT into table name (Id,name,age,status, field N) Select Id,name,age,status, field N from the name where id= ' id ';
Example: insert into user (Id,name,age,status,role) Select id,name,age,1, ' group master ' from location_user l where l.type=5;
Note: The query data must be a single piece of data
Three, small tricks
Primary key ID uniqueness, usually used in the background method (Java:uuid UUID = Uuid.randomuuid ();) insert
You can replace it with Sys_guid () later.
Example: insert into user (Id,name,age,status,role) Select Sys_guid (), name,age,1, ' group master ' fr Om location_user l where l.type=5;
or INSERT into user (Id,name,age,status,role) VALUES (Sys_guid (), ' xiaoming ', 23, 1, ' Group master ');
Iv. Other database methods similar
MySQL Database method: insert into user_t values (REPLACE (UUID (), '-', '), ' AA ', ' AA ', 22);
SQL Server database new data method: INSERT into user_t values (REPLACE (NewId (), '-', '), ' AA ', ' AA ', 22);
Oracle new data insert into finishing