14.新建测试数据库与测试表
MySQL> CREATE DATABASE mydb;
Query OK, 1 row affected (0.33 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| test|
+--------------------+
4 rows inset(0.00 sec)
mysql> use mydb;
Database changed
mysql> show create database mydb;
+----------+---------------------------------------------------------------+
| Database | Create Database |
+----------+---------------------------------------------------------------+
| mydb | CREATE DATABASE `mydb` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+---------------------------------------------------------------+
1 row inset(0.00 sec)
mysql> show tables;
Empty set(0.01 sec)
mysql> CREATE TABLE `t1` (idint(11) DEFAULT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
Query OK, 0 rows affected (0.03 sec)
mysql> show create table t1;
+-------+--------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------+
1 row inset(0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| t1 |
+----------------+
1 row inset(0.00 sec)
mysql> desc t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id| int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row inset(0.33 sec)
15.增加数据
(1).先简单插入10行数据
mysql> insert into t1 value (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
(2).查看一下
mysql> select* from t1;
+------+
| id|
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows inset(0.00 sec)
(3).插入多行数据方法
12345678910 mysql> insert into t1 select* from t1;
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> selectcount(*) from t1;
+----------+
| count(*) |
+----------+
| 20 |
+----------+
1 row inset(0.33 sec)
