mysql> SHOW DATABASES; 查看数据库信息,默认是4个库,
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> CREATE DATABASE Feiyu; 创建Feiyu数据库,
Query OK, 1 row affected (0.00 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| feiyu |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> USE Feiyu; 直接打开Feiyu数据库,
Database changed
mysql>
mysql> CREATE TABLE one( 创建one数据列表,
-> username VARCHAR (20),
-> age TINYINT UNSIGNED,
-> salary FLOAT (8,2) UNSIGNED
-> );
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW TABLES;
+-----------------+
| Tables_in_feiyu |
+-----------------+
| one |
+-----------------+
1 row in set (0.00 sec)
mysql> SHOW columns from one; one列表中的字段,
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| username | varchar(20) | YES | | NULL | |
| age | tinyint(3) unsigned | YES | | NULL | |
| salary | float(8,2) unsigned | YES | | NULL | |
+----------+---------------------+------+-----+---------+-------+
3 rows in set (0.03 sec)
mysql> INSERT INTO one 添加,
-> (username,age,salary)
-> values
-> ("one","1","1000");
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM one;
+----------+------+---------+
| username | age | salary |
+----------+------+---------+
| one | 1 | 1000.00 |
+----------+------+---------+
1 row in set (0.00 sec)
修改,
mysql> update one set username="two" where username="one";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
删除数据列表,
mysql> delete from one where username="two";
Query OK, 1 row affected (0.00 sec)
删除刚刚创建Feiyu数据库,
mysql> drop DATABASE Feiyu;
Query OK, 1 row affected (0.01 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec) 现在回到没有创建之前情形;
基础MySQL 增 删 改 查 + 删库
猜你喜欢
转载自blog.csdn.net/feiyucity/article/details/82918369
今日推荐
周排行