首先创建测试库和测试表: 1-- 创建数据库 2CREATE DATABASE dbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci; 3-- 创建表 4CREATE TABLE `tb` ( 5 `id` int(5) NOT NULL AUTO_INCREMENT, 6 `name` char(15) NOT NULL, 7 `alias` varchar(10) DEFAULT NULL, 8 `email` varchar(30) DEFAULT NULL, 9 `password` varchar(20) NOT NULL, 10 `phone` char(11) DEFAULT '13800138000', 11 PRIMARY KEY (`id`,`name`) 12) ENGINE=InnoDB DEFAULT CHARSET=utf8; 一、增加表内数据 1# 查看tb表内的内容 2mysql> select * from tb; 3Empty set (0.00 sec) 4# 插入数据 5-- 插入单条数据 6insert into tb(name,email,password) values("361way","
[email protected]","as"); 7-- 同时插入多条数据 8insert into tb(name,email,password) values("as","
[email protected]","pwd"),("info","
[email protected]","i"); 查看结果: 1mysql> select * from tb; 2+----+---------+-------+-------------------------+----------+-------------+……