数据库的一些操作:
一:数据库的操作
1:创建数据库
语法格式:
create database 数据库名;
mysql> create database test; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test | +--------------------+ 5 rows in set (0.00 sec) mysql>
2:删除数据库
语法格式:
drop database 数据库名;
mysql> drop database test; Query OK, 0 rows affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
二:表的操作
1:创建表
格式:
create table 表名(字段1[],字段2[]);
eg:
mysql> create table test1(id int,name char(20)); Query OK, 0 rows affected (0.02 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | test1 | +----------------+ 1 row in set (0.00 sec) mysql>
2:删除表
格式:
drop table 表名;
eg:
mysql> drop table test1; Query OK, 0 rows affected (0.01 sec) mysql> show tables; Empty set (0.00 sec) mysql>
三:增删改查的操作
就是针对的是数据库的数据,而不是数据库的结构
1:增加数据
格式:
insert into 表名 values(值1,值2);
eg:
mysql> insert into test1 values(1,"zhangsan"); Query OK, 1 row affected (0.00 sec) mysql> select * from test1; +------+----------+ | id | name | +------+----------+ | 1 | zhangsan | +------+----------+ 1 row in set (0.00 sec) mysql>
二:修改数据
标签:+--------------------+,test1,0.00,改查,sec,mysql,增删,数据库 From: https://www.cnblogs.com/qm77/p/17828407.html