INSERT三种插入记录的方法
1. INSERT [INTO] table_name [(column_name,…)] VALUES ({exprDEFAULT},…),(…),…;
2. INSERT [INTO] tb_name SET col_name{expr | DEFAULT},…
3. INSERT[INTO] table_name [(column_name,….)] SELECT……
CREATE TABLE user3
(
id SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(20) NOT NULL,
password VARCHAR(32) NOT NULL,
age TINYINT NOT NULL DEFAULT 18,
sex BOOLEAN
);
第三个:
INSERT user5(username) SELECT username FROM user3 WHERE id>3;