返回顶部
首页 > 资讯 > 数据库 >MYSQL 表的全面总结
  • 711
分享到

MYSQL 表的全面总结

2024-04-02 19:04:59 711人浏览 安东尼
摘要

目录1、创建表1.1、创建表基本语法1.1.1、创建一张简单的表1.1.2、查看创建表定义2、删除表3、修改表3.1、修改表类型命令3.2、字段改名命令3.3、增加表字段命令3.4、

1、创建表

1.1、创建表基本语法


CREATE TABLE tablename (column_name_1 column_type_1 constraints,
column_name_2 column_type_2 constraints , ……)


column_name 是列的名字
column_type 是列的数据类型
contraints 是这个列的约束条件

1.1.1、创建一张简单的表


Mysql> create table orders (ordername varchar(10),createtime date,ordermoney decimal(10,2),ordernumber int(2));
Query OK, 0 rows affected (0.23 sec)

1.1.2、查看创建表定义

结构化定义:


mysql> desc orders;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| ordername   | varchar(10)   | YES  |     | NULL    |       |
| createtime  | date          | YES  |     | NULL    |       |
| ordermoney  | decimal(10,2) | YES  |     | NULL    |       |
| ordernumber | int(2)        | YES  |     | NULL    |       |
+-------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

表详细定义:

查看详细的表定义:


mysql> show create table orders \G;
*************************** 1. row ***************************
       Table: orders
Create Table: CREATE TABLE `orders` (
  `ordername` varchar(10) DEFAULT NULL,
  `createtime` date DEFAULT NULL,
  `ordermoney` decimal(10,2) DEFAULT NULL,
  `ordernumber` int(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

ERROR:
No query specified


由此可以看到表的  ENGINE(存储引擎)是InnoDB

         CHARSET(字符集)是Latin1

\G”选项的含义是使得记录能够按照字段竖着排列,对于内容比较长的记录更易于显示。

2、删除表

命令:


DROP TABLE tablename


删除orders:


mysql> drop table orders
    -> ;
Query OK, 0 rows affected (0.14 sec)


3、修改表

3.1、修改表类型命令


ALTER TABLE tablename MODIFY [COLUMN] column_definition [FIRST | AFTER col_name]


例:修改表 orders name 字段定义,将 varchar(10)改为 varchar(20)


mysql> alter table orders modify ordername varchar(20);
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc orders;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| ordername   | varchar(20)   | YES  |     | NULL    |       |
| createtime  | date          | YES  |     | NULL    |       |
| ordermoney  | decimal(10,2) | YES  |     | NULL    |       |
| ordernumber | int(2)        | YES  |     | NULL    |       |
+-------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

3.2、字段改名命令


ALTER TABLE tablename CHANGE [COLUMN] old_col_name column_definition
[FIRST|AFTER col_name]


例:orders 上将ordernumber修改为ordernumbers


mysql> alter table orders change column ordernumber ordernumbers int(4);
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc orders;
+--------------+---------------+------+-----+---------+-------+
| Field        | Type          | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| ordername    | varchar(20)   | YES  |     | NULL    |       |
| createtime   | date          | YES  |     | NULL    |       |
| ordermoney   | decimal(10,2) | YES  |     | NULL    |       |
| ordernumbers | int(4)        | YES  |     | NULL    |       |
+--------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)


特别说明:change 和 modify 都可以修改表的定义,不同的是 change 后面需要写两次列名,不方便。但是 change 的优点是可以修改列名称,modify 则不能。

3.3、增加表字段命令


ALTER TABLE tablename ADD [COLUMN] column_definition [FIRST | AFTER col_name]


例:orders 上新增加字段 username,类型为 varchar(3)


mysql> alter table orders add column username varchar(30);
Query OK, 0 rows affected (0.39 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc orders;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| ordername   | varchar(20)   | YES  |     | NULL    |       |
| createtime  | date          | YES  |     | NULL    |       |
| ordermoney  | decimal(10,2) | YES  |     | NULL    |       |
| ordernumber | int(2)        | YES  |     | NULL    |       |
| username    | varchar(30)   | YES  |     | NULL    |       |
+-------------+---------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

3.4、删除表列字段命令


ALTER TABLE tablename DROP [COLUMN] col_name


例:orders 上删除字段 username


mysql> alter table orders drop column username;
Query OK, 0 rows affected (0.53 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc orders;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| ordername   | varchar(20)   | YES  |     | NULL    |       |
| createtime  | date          | YES  |     | NULL    |       |
| ordermoney  | decimal(10,2) | YES  |     | NULL    |       |
| ordernumber | int(2)        | YES  |     | NULL    |       |
+-------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

3.5、表改名命令


ALTER TABLE tablename RENAME [TO] new_tablename


例:orders 名字改为Goodsorders


mysql> alter table orders rename goodsorders;
Query OK, 0 rows affected (0.16 sec)

mysql> desc orders;
ERROR 1146 (42S02): Table 'ordermanage.orders' doesn't exist
mysql> desc goodsorders;
+--------------+---------------+------+-----+---------+-------+
| Field        | Type          | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| ordername    | varchar(20)   | YES  |     | NULL    |       |
| createtime   | date          | YES  |     | NULL    |       |
| ordermoney   | decimal(10,2) | YES  |     | NULL    |       |
| ordernumbers | int(4)        | YES  |     | NULL    |       |
+--------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
 


4、DML 语句

插入(insert)、查询(select)、更新(update)、删除(delete

4.1、插入记录 命令


INSERT INTO tablename (field1,field2,……fieldn) VALUES(value1,value2,……valuesn);


例:goodsorders 中插入一条记录,ordername zhangcreatetime2021-05-12ordermoney100.00,ordernumbers为:1


mysql> insert into goodsorders (ordername,createtime,ordermoney,ordernumbers) values('zhang','2021-05-12',100.00,1);
Query OK, 1 row affected (0.03 sec)


也可以省略(field1,field2,……fieldn)这一部分


mysql> insert into goodsorders  values('zhang1','2021-05-12',1001.00,11);
Query OK, 1 row affected (0.05 sec)

4.2、查看插入数据命令

4.2.1、查询全部


SELECT * FROM tablename [WHERE CONDITION]


例:查看goodsorders中所有插入数据


mysql> select * from goodsorders;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| zhang     | 2021-05-12 |     100.00 |            1 |
| zhang1    | 2021-05-12 |    1001.00 |           11 |
+-----------+------------+------------+--------------+
2 rows in set (0.00 sec)


其中“*”表示要将所有的记录都选出来

4.2.2、查询不重复记录命令关键字


distinct


例:查询非goodsorders中非重复创建时间(createtime)的数据


mysql> select  * from goodsorders;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| zhang     | 2021-03-11 |      50.00 |            1 |
| li        | 2020-05-12 |      70.00 |           15 |
| li        | 2020-03-12 |      70.00 |           15 |
| li        | 2020-03-11 |      70.00 |           15 |
| li        | 2021-03-11 |      70.00 |           15 |
+-----------+------------+------------+--------------+
5 rows in set (0.00 sec)

mysql> select distinct createtime from goodsorders;
+------------+
| createtime |
+------------+
| 2021-03-11 |
| 2020-05-12 |
| 2020-03-12 |
| 2020-03-11 |
+------------+
4 rows in set (0.00 sec)

由此可以看到,将重复的一条时间数据2021-03-11去掉了

4.2.3、多条件查询关键字

where 后面的条件是一个字段的‘='比较,还可以使用>、<、>=、<=、!=等比较运算符;
多个条件之间还可以使用 or、and 等逻辑运算符进行多条件联合查询,

例:查询非goodsorders ordername='li'并且createtime2020-03-11


mysql> select * from goodsorders where ordername='li'and createtime ='2020-03-11';
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| li        | 2020-03-11 |      70.00 |           15 |
+-----------+------------+------------+--------------+
1 row in set (0.00 sec)

4.2.4、排序查询命名


SELECT * FROM tablename [WHERE CONDITION] [ORDER BY field1 [DESC|ASC] , field2 
[DESC|ASC],……fieldn [DESC|ASC]]


例:goodsorders表中的记录按照创建时间高低进行排序显示


mysql> select * from goodsorders order by createtime;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| li        | 2020-03-11 |      70.00 |           15 |
| li        | 2020-03-12 |      70.00 |           15 |
| li        | 2020-05-12 |      70.00 |           15 |
| zhang     | 2021-03-11 |      50.00 |            1 |
| li        | 2021-03-11 |      70.00 |           15 |
+-----------+------------+------------+--------------+
5 rows in set (0.01 sec)

4.2.5、显示一部分,而不是全部,指令


SELECT ……[LIMIT offset_start,row_count]


offset_start 表示记录的起始偏移量
row_count 表示显示的行数

例如1:显示 goodsorders表中按照 createtiem 排序后的前 3 条记录:


mysql> select * from goodsorders order by createtime limit 3;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| li        | 2020-03-11 |      70.00 |           15 |
| li        | 2020-03-12 |      70.00 |           15 |
| li        | 2020-05-12 |      70.00 |           15 |
+-----------+------------+------------+--------------+
3 rows in set (0.00 sec)


例如2:如果要显示 goodsorders表中按照 createtiem 排序后 从第二条记录开始,显示3条数据:


mysql> select * from goodsorders order by createtime limit 2,3;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| li        | 2020-05-12 |      70.00 |           15 |
| zhang     | 2021-03-11 |      50.00 |            1 |
| li        | 2021-03-11 |      70.00 |           15 |
+-----------+------------+------------+--------------+
3 rows in set (0.00 sec)

4.2.6、统计数据,聚合指令


SELECT [field1,field2,……fieldn] fun_name 
FROM tablename
[WHERE where_contition]
[GROUP BY field1,field2,……fieldn
[WITH ROLLUP]]
[HAVING where_contition]


参数说明:

  • 1、fun_name 表示要做的聚合操作,也就是聚合函数,常用的有 sum(求和)、count(*)(记录数)、max(最大值)、min(最小值)
  • 2、GROUP BY 关键字表示要进行分类聚合的字段,比如要按照部门分类统计员工数量,部门就应该写在 group by 后面。
  • 3、WITH ROLLUP 是可选语法,表明是否对分类聚合后的结果进行再汇总。
  • 4、HAVING 关键字表示对分类后的结果再进行条件的过滤。

注意:having 和 where 的区别在于 having 是对聚合后的结果进行条件的过滤,而 where 是在聚合前就对记录进行过滤,如果逻辑允许,我们尽可能用 where 先过滤记录,这样因为结果集减小,将对聚合的效率大大提高,最后再根据逻辑看是否用 having 进行再过滤。

例1:查询统计goodsorders表中,记录总数


mysql> select count(1) from goodsorders;
+----------+
| count(1) |
+----------+
|        5 |
+----------+
1 row in set (0.00 sec)


例2:在此基础上,按照创建日期(createtime)进行分组统计


mysql> select createtime,count(1) from goodsorders group by createtime;
+------------+----------+
| createtime | count(1) |
+------------+----------+
| 2020-03-11 |        1 |
| 2020-03-12 |        1 |
| 2020-05-12 |        1 |
| 2021-03-11 |        2 |
+------------+----------+
4 rows in set (0.00 sec)


例3:在此基础上,既要按照创建日期(cretetime)进行分组统计,又要计算总数


mysql> select createtime,count(1) from goodsorders group by createtime with rollup;
+------------+----------+
| createtime | count(1) |
+------------+----------+
| 2020-03-11 |        1 |
| 2020-03-12 |        1 |
| 2020-05-12 |        1 |
| 2021-03-11 |        2 |
| NULL       |        5 |
+------------+----------+
5 rows in set (0.02 sec)


最有一行,null所展示的数字,就是总数

例4:按照创建日期(createtime)进行分组统计,并且数量大于1


mysql> select createtime,count(1) from goodsorders group by createtime having count(1)>1;
+------------+----------+
| createtime | count(1) |
+------------+----------+
| 2021-03-11 |        2 |
+------------+----------+
1 row in set (0.00 sec)


例5:查询goodsorders表中,订单金额(ordermoney)的总额、最低额、最高额


mysql> select * from goodsorders;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| zhang     | 2021-03-11 |      50.00 |            1 |
| li        | 2020-05-12 |      70.00 |           15 |
| li        | 2020-03-12 |      70.00 |           15 |
| li        | 2020-03-11 |      70.00 |           15 |
| li        | 2021-03-11 |      70.00 |           15 |
+-----------+------------+------------+--------------+
5 rows in set (0.00 sec)

mysql> select sum(ordermoney),max(ordermoney),min(ordermoney) from goodsorders;
+-----------------+-----------------+-----------------+
| sum(ordermoney) | max(ordermoney) | min(ordermoney) |
+-----------------+-----------------+-----------------+
|          330.00 |           70.00 |           50.00 |
+-----------------+-----------------+-----------------+
1 row in set (0.02 sec)

4.2.7、表连接

  • 1、左连接:包含所有的左边表中的记录甚至是右边表中没有和它匹配的记录;关键指令:left join
  • 2、右连接:包含所有的右边表中的记录甚至是左边表中没有和它匹配的记录;关联指令:right join

 例1:现在我们又创建一张用户表(member),使用goodorders进行左连接,查询关联的用户表信息


mysql> select * from member;
+------+------------+
| id   | membername |
+------+------------+
| 15   | zhang      |
| 1    | li         |
| 13   | liss       |
+------+------------+
3 rows in set (0.00 sec)

mysql> select * from goodsorders;
+-----------+------------+------------+--------------+----------+
| ordername | createtime | ordermoney | ordernumbers | memberid |
+-----------+------------+------------+--------------+----------+
| zhang     | 2021-03-11 |      50.00 |            1 | 15       |
| li        | 2020-05-12 |      70.00 |           15 | 1        |
| li        | 2020-03-12 |      70.00 |           15 | 1        |
| li        | 2020-03-11 |      70.00 |           15 | 3        |
| li        | 2021-03-11 |      70.00 |           15 | 1        |
+-----------+------------+------------+--------------+----------+
5 rows in set (0.00 sec)

mysql> select * from goodsorders left join member on goodsorders.memberid = member.id;
+-----------+------------+------------+--------------+----------+------+------------+
| ordername | createtime | ordermoney | ordernumbers | memberid | id   | membername |
+-----------+------------+------------+--------------+----------+------+------------+
| zhang     | 2021-03-11 |      50.00 |            1 | 15       | 15   | zhang      |
| li        | 2020-05-12 |      70.00 |           15 | 1        | 1    | li         |
| li        | 2020-03-12 |      70.00 |           15 | 1        | 1    | li         |
| li        | 2021-03-11 |      70.00 |           15 | 1        | 1    | li         |
| li        | 2020-03-11 |      70.00 |           15 | 3        | NULL | NULL       |
+-----------+------------+------------+--------------+----------+------+------------+
5 rows in set (0.00 sec)

 例2membergoodsorders中数据不变,我们再来看一下右连接的查询,以及结果:


mysql> select * from goodsorders right join member on goodsorders.memberid = member.id;
+-----------+------------+------------+--------------+----------+------+------------+
| ordername | createtime | ordermoney | ordernumbers | memberid | id   | membername |
+-----------+------------+------------+--------------+----------+------+------------+
| zhang     | 2021-03-11 |      50.00 |            1 | 15       | 15   | zhang      |
| li        | 2020-05-12 |      70.00 |           15 | 1        | 1    | li         |
| li        | 2020-03-12 |      70.00 |           15 | 1        | 1    | li         |
| li        | 2021-03-11 |      70.00 |           15 | 1        | 1    | li         |
| NULL      | NULL       |       NULL |         NULL | NULL     | 13   | liss       |
+-----------+------------+------------+--------------+----------+------+------------+
5 rows in set (0.00 sec)

这里发生了翻转,变为左侧goodsorders 表中的一条数据为空了

4.2.8、子查询,相关关键字

主要包括 innot in=!=existsnot exists

例:goodsorders表中查询所有用户在memeber表中的记录


mysql> select * from member;
+------+------------+
| id   | membername |
+------+------------+
| 15   | zhang      |
| 1    | li         |
| 13   | liss       |
+------+------------+
3 rows in set (0.00 sec)

mysql> select * from goodsorders;
+-----------+------------+------------+--------------+----------+
| ordername | createtime | ordermoney | ordernumbers | memberid |
+-----------+------------+------------+--------------+----------+
| zhang     | 2021-03-11 |      50.00 |            1 | 15       |
| li        | 2020-05-12 |      70.00 |           15 | 1        |
| li        | 2020-03-12 |      70.00 |           15 | 1        |
| li        | 2020-03-11 |      70.00 |           15 | 3        |
| li        | 2021-03-11 |      70.00 |           15 | 1        |
+-----------+------------+------------+--------------+----------+
5 rows in set (0.00 sec)

mysql> select * from goodsorders where memberid in(select id from member);
+-----------+------------+------------+--------------+----------+
| ordername | createtime | ordermoney | ordernumbers | memberid |
+-----------+------------+------------+--------------+----------+
| zhang     | 2021-03-11 |      50.00 |            1 | 15       |
| li        | 2020-05-12 |      70.00 |           15 | 1        |
| li        | 2020-03-12 |      70.00 |           15 | 1        |
| li        | 2021-03-11 |      70.00 |           15 | 1        |
+-----------+------------+------------+--------------+----------+
4 rows in set (0.05 sec)

4.2.9、记录联合,指令


SELECT * FROM t1
UNION|UNION ALL
SELECT * FROM t2
……
UNION|UNION ALL
SELECT * FROM tn;


UNION UNION ALL 的主要区别:

     UNION ALL 是把结果集直接合并在一起,
     UNION 是将UNION ALL 后的结果进行一次 DISTINCT,去除重复记录后的结果。

例1:member表和goodsorders表中的用户编号id(memberid)的集合显示出来


mysql> select memberid from goodsorders union all select id from member;
+----------+
| memberid |
+----------+
| 15       |
| 1        |
| 1        |
| 3        |
| 1        |
| 15       |
| 1        |
| 13       |
+----------+
8 rows in set (0.00 sec)

例2:如果希望将上面的结果去掉重复记录后显示


mysql> select memberid from goodsorders union select id from member;
+----------+
| memberid |
+----------+
| 15       |
| 1        |
| 3        |
| 13       |
+----------+
4 rows in set (0.00 sec)

4.3、更新记录命令


UPDATE tablename SET field1=value1,field2.=value2,……fieldn=valuen [WHERE CONDITION]


例:将表 goodsorders ordernamezhang的订单金额(ordermoney)改为50


mysql> update goodsorders set ordermoney=50.00 where ordername='zhang';
Query OK, 1 row affected (0.09 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from goodsorders;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| zhang     | 2021-05-12 |      50.00 |            1 |
| zhang1    | 2021-05-12 |    1001.00 |           11 |
+-----------+------------+------------+--------------+
2 rows in set (0.00 sec)

更新时,如遇到错误代码1175:

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences

解决方法:

1、先进行状体查询:


show variables like 'SQL_SAFE_UPDATES';


2、执行下面的sql,关闭safe-updates模式:


SET SQL_SAFE_UPDATES = 0;


或者


SET SQL_SAFE_UPDATES = false;
 

4.4、删除记录命名


DELETE FROM tablename [WHERE CONDITION]


例:将表 goodsorders ordernamezhang1的记录全部删除


mysql> delete from goodsorders where ordername = 'zhang1';
Query OK, 1 row affected (0.06 sec)

mysql> select * from goodsorders;
+-----------+------------+------------+--------------+
| ordername | createtime | ordermoney | ordernumbers |
+-----------+------------+------------+--------------+
| zhang     | 2021-05-12 |      50.00 |            1 |
+-----------+------------+------------+--------------+
1 row in set (0.02 sec)
 


4.5、初始化表

例:将表中的所有数据清空


mysql> select * from varc;
+------+------+
| v    | c    |
+------+------+
| abc  | abc  |
+------+------+
1 row in set (0.03 sec)

mysql> truncate table varc;
Query OK, 0 rows affected (0.25 sec)

mysql> select * from varc;
Empty set (0.00 sec)
 

5、DCL 语句

DCL语句主要是为了管理数据库系统中的操作对象权限

5.1创建数据库用户

例:创建一个数据库用户 user1,初始密码为123,具有对 ordermanage 数据库中所有表的 SELECT/INSERT 权限:


mysql> grant select,insert on ordermanage.* to 'user1'@'localhost' identified by '123';
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> exit
Bye


C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uuser1 -p123
mysql: [Warning] Using a passWord on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 82
Server version: 5.7.17-log MySQL CommUnity Server (GPL)

Copyright (c) 2000, 2016, oracle and/or its affiliates. All rights reserved.

Oracle is a reGIStered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| infORMation_schema |
| ordermanage        |
+--------------------+
2 rows in set (0.00 sec)

在此基础上,将此用户(user1)的insert权限进行收回


mysql> revoke insert on ordermanage.* from 'user1'@'localhost';
Query OK, 0 rows affected (0.02 sec)

mysql> exit
Bye

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uuser1 -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use ordermanage;
Database changed

mysql> insert into member values('11','ss');
ERROR 1142 (42000): INSERT command denied to user 'user1'@'localhost' for table 'member'
mysql>

由此可以看出插入权限不足,插入失败

到此这篇关于MYSQL表的介绍的文章就介绍到这了,更多相关MYSQL表内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

您可能感兴趣的文档:

--结束END--

本文标题: MYSQL 表的全面总结

本文链接: https://lsjlt.com/news/156839.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • MYSQL 表的全面总结
    目录1、创建表1.1、创建表基本语法1.1.1、创建一张简单的表1.1.2、查看创建表定义2、删除表3、修改表3.1、修改表类型命令3.2、字段改名命令3.3、增加表字段命令3.4、...
    99+
    2024-04-02
  • MySQL GTID全面总结
    01 GTID简介       GTID,全称Global transaction identifiers,也称之为全局事务ID。MySQL-5.6.2开始支持,M...
    99+
    2022-05-27
    MySQL GTID
  • mysql函数全面总结
    目录1、MySQL中常用字符串函数2、数值函数3、日期和时间函数4、流程函数5、其他常用函数1、MySQL中常用字符串函数 函...
    99+
    2024-04-02
  • Android中Service的全面总结
    全面总结Android Service的使用方法,具体内容如下1、Service的种类按运行地点分类:其实remote服务还是很少见的,并且一般都是系统服务。按运行类型分类:有同学可能会问,后台服务我们可以自己创建 ONGOING 的 No...
    99+
    2023-05-31
    android service roi
  • MySQL面试总结
    MySQL面试总结 # MySQL的存储引擎 `MyISAM`(默认表类型):非事务的存储引擎,基于传统的`ISAM`(有索引的顺序访问方法)类型,是存储记录和文件的标准方法,不是事务安全,不支持外键,适用于频繁的查询。表锁,不会出现死锁,...
    99+
    2021-08-21
    MySQL面试总结
  • Android中的Service相关全面总结
    1、Service的种类 按运行地点分类: 类别 区别  优点 缺点   应用 本地服务(Local) 该服务依附在主进程上, &nbs...
    99+
    2022-06-06
    service Android
  • Android数据结构全面总结分析
    前言 这次算一个总结,我们平时都会用到各种各样的数据结构,但是可能从未看过它们内部是如何去实现的。只有了解了它们内部大概的一个实现原理,才能在不同的场景中能选出最适合这个场景的数据结...
    99+
    2022-12-08
    Android 数据结构 Android 数据结构总结分析
  • AndroidMap数据结构全面总结分析
    目录前言MapArrayMapTreeMapHashMap总结前言 上一篇讲了Collection、Queue和Deque、List或Set,没看的朋友可以去简单看看,这一篇主要讲和...
    99+
    2022-12-08
    Android Map数据结构 Android Map
  • Spring-全面详解(学习总结)
    目录一、Spring介绍简介特点、主要特点为什么要学?二、IOC(依赖注入)Spring 容器IOC 和 bean介绍控制反转:容器概述:bean介绍AOP总结一、Spring介绍 ...
    99+
    2024-04-02
  • Spring全面详解(学习总结)
    Spring FrameWork一、 前言二、IOC(控制反转)2.1 对于IOC的理解2.2如何使用IOC2.3配置文件的解读2.4IOC容器创建bean的两种方式2.5从IOC容器中取bean2.6bean的属性如...
    99+
    2023-08-16
    spring java IOC AOP
  • MySQL表和列的注释总结
    像代码一样,可以为表以及表中的列添加注释,方便其他人知晓其功能。对于一些字段,在经过一定时间后,创建者未必也能想起其具体的含意,所以注释显得尤为重要。 注释的添加 注释的添加是通过在定义表或列的时候在末尾加...
    99+
    2024-04-02
  • mysql中表的知识点总结
    这篇文章主要介绍“mysql中表的知识点总结”,在日常操作中,相信很多人在mysql中表的知识点总结问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”mysql中表的知识点总结”...
    99+
    2024-04-02
  • mysql知识点+面试总结
    目录 1 mysql介绍 2 数据库常见语法 3 数据库表的常见语法 4 其他常见语法(日期,查询表字段) 5 JDBC开发步骤 6 索引 6.1 索引常见语法 7 常见面试总结 8 java集成数据库监控页面 1 mysql介绍 ...
    99+
    2023-09-04
    mysql 面试 数据库
  • MYSQL表的全面分析
    这篇文章主要介绍“MYSQL表的全面分析”,在日常操作中,相信很多人在MYSQL表的全面分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MYSQL表的全面分析”的疑惑有所帮助!接下来,请跟着小编一起来学习吧...
    99+
    2023-06-25
  • mysql表分区实验总结
    草稿丢失,发表得不完整,稍后重新整理mysql表分区技术能有效解决水平拆分和垂直拆分的不足,可操作性和效率都更优。以下是一些实验总结。InnoDB引擎需先在配置文件中设置: innodb_file...
    99+
    2024-04-02
  • 全面总结Vue3.0的多种侦听方式
    目录侦听器一、wacthEffect二、watch1.1第一种方式侦听1.2第二种方式侦听1.3侦听多个数据源总结侦听器 虽然计算属性在大多数情况下更合适,但有时也需要一个自定义的...
    99+
    2024-04-02
  • Flutter Form表单控件超全总结
    注意:无特殊说明,Flutter版本及Dart版本如下:Flutter版本: 1.12.13+hotfix.5 Dart版本: 2.7.0Form、FormField、TextFormField是表单相关控件,类似于H5中form。Form...
    99+
    2023-06-04
  • mysql查看表结构的三种方法总结
    目录mysql查看表结构1. show create table2. desc3. information_schema.COLUMNS获取所有的表结构及备注根据库名导出所有表信息根据库名导出所有表名及表备注mysql获...
    99+
    2022-07-06
    mysql表结构 查看表结构 表结构查看
  • mysql关于memory引擎的表的总结
    参见官方文档https://dev.mysql.com/doc/refman/5.7/en/memory-storage-engine.html 总结 1、memory引擎表数据只存...
    99+
    2024-04-02
  • MySQL分库分表总结讲解
    项目开发中,我们的数据库数据越来越大,随之而来的是单个表中数据太多。以至于查询变慢,而且由于表的锁机制导致应用操作也受到严重影响,出现了数据库性能瓶颈。 当出现这种情况时,我们可以考虑分库分表,即将单个数据...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作