MySQL表操作

1.介绍

  表就相当于文件,表中的一条记录就相当与文件的一行内容,不同的是,表中的一条记录有对应的标题,成为表的字段。

2.创建表

2.1语法

create table 表名(
字段名1 类型[(宽度) 约束条件],
字段名2 类型[(宽度) 约束条件],
字段名3 类型[(宽度) 约束条件],
); 注意:
1. 必须进入数据库中才能创建表
2. 标点符号均为英文标点符号
3. 在同一张表中,字段名是不能相同的
4. 宽度和约束条件为可选项
5. 字段名和类型是必须的

2.2范例

1-使用默认格式创建表

mysql> use python25;
Database changed
mysql> show tables;
Empty set (0.00 sec) mysql> create table test1(id int,
-> name char(11),
-> sex enum('male', 'female'),
-> hobby set('swiming', 'running', 'basketball'));
Query OK, 0 rows affected (0.02 sec) mysql> desc test1;
+-------+---------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| hobby | set('swiming','running','basketball') | YES | | NULL | |
+-------+---------------------------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

2-自定义格式创建表

# 指定字符编码
mysql> create table test3 (
-> id int,
-> name char(10),
-> age int,
-> sex enum('male', 'female'),
-> phone char(11),
-> job char(10)
-> ) charset=utf8;
Query OK, 0 rows affected (0.03 sec) #指定存储引擎
mysql> create table test4 (
-> id int,
-> name char(10),
-> age int,
-> sex enum('male', 'female'),
-> phone char(11),
-> job char(10)
-> ) ENGINE=MyISAM;
Query OK, 0 rows affected (0.01 sec)

3-查看表结构、创建表的语句

# 查看表结构
mysql> show columns from test1;
+-------+---------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| hobby | set('swiming','running','basketball') | YES | | NULL | |
+-------+---------------------------------------+------+-----+---------+-------+
4 rows in set (0.00 sec) mysql> desc test1;
+-------+---------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| hobby | set('swiming','running','basketball') | YES | | NULL | |
+-------+---------------------------------------+------+-----+---------+-------+
4 rows in set (0.00 sec) # 查看创建表的语句
mysql> show create table test1 \G;
*************************** 1. row ***************************
Table: test1
Create Table: CREATE TABLE `test1` (
`id` int(11) DEFAULT NULL,
`name` char(11) DEFAULT NULL,
`sex` enum('male','female') DEFAULT NULL,
`hobby` set('swiming','running','basketball') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

2.删除表

语法:

DROP TABLE 表名;

注意:删表要谨慎

mysql> show tables;
+--------------------+
| Tables_in_python25 |
+--------------------+
| test1 |
| test2 |
| test3 |
| test4 |
+--------------------+
4 rows in set (0.00 sec) mysql> drop table test1;
Query OK, 0 rows affected (0.01 sec) mysql> drop table test2;
Query OK, 0 rows affected (0.01 sec) mysql> show tables;
+--------------------+
| Tables_in_python25 |
+--------------------+
| test3 |
| test4 |
+--------------------+
2 rows in set (0.00 sec)

3.修改表

3.1 修改表名

语法

ALTER TABLE 表名 RENAME 新表名;

范例

mysql> show tables;
+--------------------+
| Tables_in_python25 |
+--------------------+
| test3 |
| test4 |
+--------------------+
2 rows in set (0.00 sec) mysql> alter table test3 rename test1;
Query OK, 0 rows affected (0.02 sec) mysql> show tables;
+--------------------+
| Tables_in_python25 |
+--------------------+
| test1 |
| test4 |
+--------------------+
2 rows in set (0.00 sec)

3.2 增加字段

语法

ALTER TABLE 表名 ADD 字段名 数据类型[(宽度) 约束条件], ADD 字段名 数据类型[(宽度) 约束条件];

范例

mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(10) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.01 sec) # 增加hobby、home两个字段
mysql> alter table test1 add hobby set('football', 'running'), add home char(10);
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+---------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(10) | YES | | NULL | |
| hobby | set('football','running') | YES | | NULL | |
| home | char(10) | YES | | NULL | |
+-------+---------------------------+------+-----+---------+-------+
8 rows in set (0.00 sec)

3.3 删除字段

语法

ALTER TABLE 表名 DROP 字段名;

范例

mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(10) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.01 sec) # 删除hobby、home字段
mysql> alter table test1 add hobby set('football', 'running'), add home char(10);
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+---------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(10) | YES | | NULL | |
| hobby | set('football','running') | YES | | NULL | |
| home | char(10) | YES | | NULL | |
+-------+---------------------------+------+-----+---------+-------+
8 rows in set (0.00 sec)

3.4 修改字段

语法

ALTER TABLE 表名 MODIFY 字段名 数据类型[(宽度) 约束条件];

ALTER TABLE 表名 CHANGE 旧字段名 新字段名 旧数据类型[(宽度) 约束条件];

ALTER TABLE 表名 CHANGE 旧字段名 新字段名 新数据类型[(宽度) 约束条件];

范例

mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(10) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.00 sec) # 修改job字段的数据类型
mysql> alter table test1 modify job varchar(11);
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | varchar(11) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.01 sec) # 修改job字段为hobby字段
mysql> alter table test1 change job hobby varchar(11);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| hobby | varchar(11) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.00 sec) # 修改hobby字段为job字段,且数据类型改为char
mysql> alter table test1 change hobby job char(11);
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.01 sec)

3.5 修改字段排列顺序、在增加的时候指定字段位置

语法

ALTER TABLE 表名 ADD 字段名 数据类型 [(宽度) 约束条件] FIRST;

ALTER TABLE 表名 ADD 字段名 数据类型 [(宽度) 约束条件] AFTER 字段名;

ALTER TABLE 表名 CHANGE 字段名 旧字段名 新字段名 新数据类型 [(宽度) 约束条件] FIRST;

ALTER TABLE 表名 MODIFY 字段名 数据类型 [(宽度) 约束条件] AFTER 字段名;

范例

mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
6 rows in set (0.01 sec) # 在表的开头添加hobby字段
mysql> alter table test1 add hobby char(10) first;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+-------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------------+------+-----+---------+-------+
| hobby | char(10) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
+-------+-----------------------+------+-----+---------+-------+
7 rows in set (0.00 sec) # 在job字段后面添加salary字段
mysql> alter table test1 add salary int after job;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+--------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------------+------+-----+---------+-------+
| hobby | char(10) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
| salary | int(11) | YES | | NULL | |
+--------+-----------------------+------+-----+---------+-------+
8 rows in set (0.00 sec) # 修改hobby字段名为aihao
mysql> alter table test1 change hobby aihao char(10) first;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+--------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------------+------+-----+---------+-------+
| aihao | char(10) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
| salary | int(11) | YES | | NULL | |
+--------+-----------------------+------+-----+---------+-------+
8 rows in set (0.00 sec) # 把aihao字段放到salary字段后面
mysql> alter table test1 modify aihao char(10) after salary;
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> desc test1;
+--------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | char(10) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | enum('male','female') | YES | | NULL | |
| phone | char(11) | YES | | NULL | |
| job | char(11) | YES | | NULL | |
| salary | int(11) | YES | | NULL | |
| aihao | char(10) | YES | | NULL | |
+--------+-----------------------+------+-----+---------+-------+
8 rows in set (0.00 sec)

4.数据操作

创建表

# 创建语句
create table teacher(
id int primary key,
name char(10) not null,
age int,
hire_date datetime,
sex enum('male', 'female') not null default 'male',
phone char(11) unique,
salary float(8, 2),
hobby set('running', 'football', 'basketball'),
comment varchar(255)
); # 查看表结构
mysql> desc teacher;
+-----------+----------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------------------------------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | char(10) | NO | | NULL | |
| age | int(11) | YES | | NULL | |
| hire_date | datetime | YES | | NULL | |
| sex | enum('male','female') | NO | | male | |
| phone | char(11) | YES | UNI | NULL | |
| salary | float(8,2) | YES | | NULL | |
| hobby | set('running','football','basketball') | YES | | NULL | |
| comment | varchar(255) | YES | | NULL | |
+-----------+----------------------------------------+------+-----+---------+-------+
9 rows in set (0.00 sec)

4.1 插入数据

语法

插入单行数据,

INSERT INTO 表名 (字段1, 字段2, 字段3...) value (值1, 值2, 值3);

如果不添加字段名称,插入的数据需要与表里的字段一一对应

INSERT INTO 表名 value (值1, 值2, 值3);

插入多行数据

INSERT INTO 表名 values (值1, 值2, 值3),(值1, 值2, 值3),(值1, 值2, 值3);

范例

#  插入单条数据,注意float类型会进行四舍五入
mysql> insert into teacher (id, name, hobby) value (1, 'zhangsan', 'running');
Query OK, 1 row affected (0.42 sec) mysql> select * from teacher;
+----+----------+------+-----------+------+-------+--------+---------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+----------+------+-----------+------+-------+--------+---------+---------+
| 1 | zhangsan | NULL | NULL | male | NULL | NULL | running | NULL |
+----+----------+------+-----------+------+-------+--------+---------+---------+
1 row in set (0.00 sec) mysql> insert into teacher value (2, 'lisi', 30, '2017-10-20', 'male', '13069948980', 2000, 'basketball', 'haha');
Query OK, 1 row affected (0.15 sec) mysql> select * from teacher;
+----+----------+------+---------------------+------+-------------+---------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+----------+------+---------------------+------+-------------+---------+------------+---------+
| 1 | zhangsan | NULL | NULL | male | NULL | NULL | running | NULL |
| 2 | lisi | 30 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
+----+----------+------+---------------------+------+-------------+---------+------------+---------+
2 rows in set (0.03 sec) # 插入多条数据
mysql> insert into teacher values (3, 'wangwu', 28, '2016-11-20', 'male', '1382333333', 20000, 'football', 'wowo'),
-> (4, 'xiaoli', 28, '2015-11-20', 'female', '13823333333', 20000, 'football', 'wowo');
Query OK, 2 rows affected (0.40 sec)
Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from teacher;
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
| 1 | zhangsan | NULL | NULL | male | NULL | NULL | running | NULL |
| 2 | lisi | 30 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
| 3 | wangwu | 28 | 2016-11-20 00:00:00 | male | 1382333333 | 20000.00 | football | wowo |
| 4 | xiaoli | 28 | 2015-11-20 00:00:00 | female | 13823333333 | 20000.00 | football | wowo |
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
4 rows in set (0.00 sec)

4.2 删除数据

语法

DELETE FROM 表名 WHERE ....;

范例

mysql> select * from teacher;
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
| 1 | zhangsan | NULL | NULL | male | NULL | NULL | running | NULL |
| 2 | lisi | 30 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
| 3 | wangwu | 28 | 2016-11-20 00:00:00 | male | 1382333333 | 20000.00 | football | wowo |
| 4 | xiaoli | 28 | 2015-11-20 00:00:00 | female | 13823333333 | 20000.00 | football | wowo |
+----+----------+------+---------------------+--------+-------------+----------+------------+---------+
4 rows in set (0.00 sec) mysql> delete from teacher where id=1;
Query OK, 1 row affected (0.48 sec) mysql> select * from teacher;
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| 2 | lisi | 30 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
| 3 | wangwu | 28 | 2016-11-20 00:00:00 | male | 1382333333 | 20000.00 | football | wowo |
| 4 | xiaoli | 28 | 2015-11-20 00:00:00 | female | 13823333333 | 20000.00 | football | wowo |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
3 rows in set (0.00 sec)

4.3 更新数据

语法

UPDATE 表名 SET 字段1=值1, 字段2=值2 WHERE ...;

范例

mysql> select * from teacher;
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| 2 | lisi | 30 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
| 3 | wangwu | 28 | 2016-11-20 00:00:00 | male | 1382333333 | 20000.00 | football | wowo |
| 4 | xiaoli | 28 | 2015-11-20 00:00:00 | female | 13823333333 | 20000.00 | football | wowo |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
3 rows in set (0.00 sec) mysql> update teacher set age=40 where id=2;
Query OK, 1 row affected (0.46 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from teacher;
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| id | name | age | hire_date | sex | phone | salary | hobby | comment |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
| 2 | lisi | 40 | 2017-10-20 00:00:00 | male | 13069948980 | 2000.00 | basketball | haha |
| 3 | wangwu | 28 | 2016-11-20 00:00:00 | male | 1382333333 | 20000.00 | football | wowo |
| 4 | xiaoli | 28 | 2015-11-20 00:00:00 | female | 13823333333 | 20000.00 | football | wowo |
+----+--------+------+---------------------+--------+-------------+----------+------------+---------+
3 rows in set (0.00 sec)

4.4 查询数据

单表查询

多表查询

03-MySQL表操作的更多相关文章

  1. Python 3 mysql 表操作

    Python 3 mysql 表操作 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,称为表的字段 id,name,qq,age称为字段,其余的,一行内容称为 ...

  2. 8.3 mysql 表操作

    库操作 一 系统数据库 information_schema: 虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限信息.字符信息等    performance_sch ...

  3. 数据库 -- mysql表操作

    一,存储引擎介绍 存储引擎即表类型,mysql根据不同的表类型会有不同的处理机制 详见:https://www.cnblogs.com/peng104/p/9751738.html 二,表介绍 表相当 ...

  4. MySQL表操作及数据操作

    表操作 表相当于一个文件,其形式与现实中的表格相同.表中的每条记录都有相应的字段,字段就类似于表格的表头. 表操作详细: #对表进行操作(文件) #首先要切换到指定库(即文件夹)下:use db1; ...

  5. 细说MySQL表操作

    目录 语法 查看表结构 查看所有的表 删除表 查看创建表的语句 修改表的字符集和校验规则 修改表名 在表中添加新字段 修改表的字段名 修改表中字段的属性 删除表中的某个字段 设置某个字段为主键 把某个 ...

  6. mysql表操作与权限操作

    修改表ALTER TABLE 语法: . 修改表名 ALTER TABLE 表名 RENAME 新表名; . 增加字段 ALTER TABLE 表名 ADD 字段名 数据类型 [完整性约束条件…], ...

  7. mysql数据库从删库到跑路之mysql表操作

    表介绍 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,称为表的字段 id,name,qq,age称为字段,其余的,一行内容称为一条记录 内容: 1 创建表 ...

  8. MySQL 表操作 (Day40)

    阅读目录 一.表介绍 二.创建表 三.查看表 四.修改表 五.删除表 六.操作表中的记录 一.表介绍 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,则称为表 ...

  9. Mysql表操作

    查看表结构: 可以使用describe或show create table语句查看表的结构: describe表名; Show create table 表名; 修改表名: Alter table 旧 ...

  10. mysql 表操作

    创建表 简单的方式 CREATE TABLE person ( number INT(11), name VARCHAR(255), birthday DATE ); 或者是 CREATE TABLE ...

随机推荐

  1. 使用 shell / python 进行sql的excel报表导出

    如果要求你进行一个表数据的导出,如果使用shell的话,很容易做到,即执行一下 select 语句就可以拿到返回结果了! 如下: /usr/bin/mysql -u"${username}& ...

  2. 从壹开始前后端分离 [ vue + .netcore 补充教程 ] 三十║ Nuxt实战:动态路由+同构

    上期回顾 说接上文<二九║ Nuxt实战:异步实现数据双端渲染>,昨天咱们通过项目二的首页数据处理,简单了解到了 nuxt 异步数据获取的作用,以及亲身体验了几个重要文件夹的意义,整篇文章 ...

  3. mysql error 2005 - Unknown MySQL server host 'localhost'(11001)

    有的时候偶尔会出现这个问题 2005 Unknown MySQL server host 'localhost' (11001),刚开始重启电脑ok了,但是不能每次出现这个问题就重启电脑吧,太麻烦了, ...

  4. SpinnerViewPop【PopWindow样式(单选)、Dialog样式(单选+多选)的下拉菜单】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 对下拉菜单的文本区域和列表区域进行了封装.包括两种展现方式:popwindow(单选).dialog(单选+多选) 因为该封装需要在 ...

  5. 接口测试---Python数据处理需要注意的细节

    一.json模块中的dumps方法 请求接口时params肯定是dict类型的,就是这种{"A":"B"},因为需要传json格式的参数到服务端,但是为了降低c ...

  6. 【Python3爬虫】使用异步协程编写爬虫

    一.基本概念 进程:进程是一个具有独立功能的程序关于某个数据集合的一次运行活动.进程是操作系统动态执行的基本单元. 线程:一个进程中包含若干线程,当然至少有一个线程,线程可以利用进程所拥有的资源.线程 ...

  7. 深入Go的底层,带你走近一群有追求的人

    目录 缘起 自我介绍的技巧 硬核知识点 什么是plan9汇编 汇编角度看函数调用及返回过程 汇编角度看slice 正确参与Go夜读活动的方式 阅读原文 上周六晚上,我参加了"Go夜读&quo ...

  8. 西安活动 | 2019年1月13号 "拥抱开源, 又见.NET" 线下交流活动报名进行中

    随着.NET Core的发布和开源,.NET又重新回到人们的视野..NET Core的下个3.0即将release,加入非常多的新功能,越来越拥抱变化,DevOps和Microservice的最佳实践 ...

  9. 微信公众号开发C#系列-1、微信公众平台注册

    微信公众号简介 微信公众号分为服务号.订阅号.企业号,订阅号可以个人申请,服务号和企业号要有企业资质才可以. 我们所说的微信公众号开发主要指的是公众号的账号类型,公众号的账号类型分为订阅号.服务号.企 ...

  10. Springboot 系列(九)使用 Spring JDBC 和 Druid 数据源监控

    前言 作为一名 Java 开发者,相信对 JDBC(Java Data Base Connectivity)是不会陌生的,JDBC作为 Java 基础内容,它提供了一种基准,据此可以构建更高级的工具和 ...