MySQL 使用

2019-01-31  本文已影响0人  simplehych
// 查看所有数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| springbootdb       |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

// 更换数据库
mysql> use springbootdb;
Database changed

// 查看当前数据库
mysql> select database();
+--------------+
| database()   |
+--------------+
| springbootdb |
+--------------+
1 row in set (0.00 sec)

// 删除表
mysql> drop table if exists `city`;
Query OK, 0 rows affected, 1 warning (0.01 sec)

// 创建表
mysql> CREATE TABLE `city` (
    ->   `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '城市编号',
    ->   `province_id` int(10) unsigned  NOT NULL COMMENT '省份编号',
    ->   `city_name` varchar(25) DEFAULT NULL COMMENT '城市名称',
    ->   `description` varchar(25) DEFAULT NULL COMMENT '描述',
    ->   PRIMARY KEY (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected, 1 warning (0.03 sec)

// 查看当前数据库表
mysql> show tables;                                                             
+------------------------+
| Tables_in_springbootdb |
+------------------------+
| city                   |
+------------------------+
1 row in set (0.00 sec)

// 插入数据
mysql> insert city values (1,1,'温岭市','BYSocket 的家在温岭') ;
Query OK, 1 row affected (0.18 sec)
上一篇 下一篇

猜你喜欢

热点阅读