mariadb(mysql)[详解]

时间:2022-06-18 04:09:50

本文链接:https://blog.csdn.net/root__oo7/article/details/82817501

安装:
 
[[email protected] ~]# yum install mariadb -y #客户端

[[email protected] ~]# yum install mariadb-server -y #服务端
启动服务:
[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# ss -tnl | grep 3306 #查看端口确定是否被监听
LISTEN 0 50 *:3306 *:*

说明:若是mysql启动 将mariadb改为mysql即可
进入mariadb:
[[email protected] ~]# mysql #注意
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>
初始化mariadb:
[[email protected] ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we‘ll need the current
password for the root user. If you‘ve just installed MariaDB, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): #直接回车即可
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y #是否设置mariadb中root用户的密码
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y #删除匿名用户
... Success!

Normally, root should only be allowed to connect from ‘localhost‘. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n #是否允许root远程连接
... skipping.

By default, MariaDB comes with a database named ‘test‘ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y #是否删除test这个测试库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y #是否重新加载权限表
... Success!

Cleaning up...

All done! If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
数据库及表的查询:

MariaDB [(none)]> show databases; #数据库的查询
--------------------
| Database |
--------------------
| hellodb |
| information_schema |
| mage |
| mysql |
| performance_schema |
--------------------
5 rows in set (0.16 sec)

MariaDB [(none)]> use hellodb; #进入指定的数据库
Database changed
MariaDB [hellodb]> show tables; #数据库中表的查询
-------------------
| Tables_in_hellodb |
-------------------
| classes |
| coc |
| courses |
| scores |
| students |
| teachers |
| toc |
-------------------
7 rows in set (0.07 sec)


MariaDB [hellodb]> desc classes; #表的描述
---------- ---------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
---------- ---------------------- ------ ----- --------- ----------------
| ClassID | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
| Class | varchar(100) | YES | | NULL | |
| NumOfStu | smallint(5) unsigned | YES | | NULL | |
---------- ---------------------- ------ ----- --------- ----------------
3 rows in set (0.14 sec)

MariaDB [hellodb]> select * from classes; #查询表的全部内容
--------- ---------------- ----------
| ClassID | Class | NumOfStu |
--------- ---------------- ----------
| 1 | Shaolin Pai | 10 |
| 2 | Emei Pai | 7 |
| 3 | QingCheng Pai | 11 |
| 4 | Wudang Pai | 12 |
| 5 | Riyue Shenjiao | 31 |
| 6 | Lianshan Pai | 27 |
| 7 | Ming Jiao | 27 |
| 8 | Xiaoyao Pai | 15 |
--------- ---------------- ----------
8 rows in set (0.05 sec)
MariaDB [hellodb]> select class from classes; #查询表的指定列
----------------
| class |
----------------
| Shaolin Pai |
| Emei Pai |
| QingCheng Pai |
| Wudang Pai |
| Riyue Shenjiao |
| Lianshan Pai |
| Ming Jiao |
| Xiaoyao Pai |
----------------
8 rows in set (0.05 sec)

MariaDB [hellodb]> select * from classes where classid=2; #按条件查询
--------- ---------- ----------
| ClassID | Class | NumOfStu |
--------- ---------- ----------
| 2 | Emei Pai | 7 |
--------- ---------- ----------
1 row in set (0.08 sec)

数据库及表的创建:
MariaDB [(none)]> create database zxl; #数据库的创建
Query OK, 1 row affected (0.20 sec)

MariaDB [(none)]> show databases; #显示库
--------------------
| Database |
--------------------
| hellodb |
| information_schema |
| mage |
| mysql |
| performance_schema |
| zxl |
--------------------
6 rows in set (0.00 sec)

MariaDB [(none)]> use zxl; #进入指定的库
Database changed
MariaDB [zxl]> show tables; #显示库里的表
Empty set (0.00 sec)

MariaDB [zxl]> create table M33; #不指定列的情况下表的创建是不可以的
ERROR 1113 (42000): A table must have at least 1 column
MariaDB [zxl]> create table M33(id tinyint unsigned primary key,name varchar(20)); #创建表(主键在此可以定义,但不是仅可以在此定义)
Query OK, 0 rows affected (0.33 sec)

MariaDB [zxl]> show tables; #显示所有的表
---------------
| Tables_in_zxl |
---------------
| M33 |
---------------
1 row in set (0.00 sec)

MariaDB [zxl]> desc M33; #描述表
------- --------------------- ------ ----- --------- -------
| Field | Type | Null | Key | Default | Extra |
------- --------------------- ------ ----- --------- -------
| id | tinyint(3) unsigned | NO | PRI | NULL | |
| name | varchar(20) | YES | | NULL | |
------- --------------------- ------ ----- --------- -------
2 rows in set (0.00 sec)
表数据的增删改:
MariaDB [zxl]> insert into M33 values(1,‘zhangsan‘); #数据的插入
Query OK, 1 row affected (0.08 sec)

MariaDB [zxl]> select * from M33;
---- ----------
| id | name |
---- ----------
| 1 | zhangsan |
---- ----------
1 row in set (0.00 sec)
MariaDB [zxl]> insert into M33 (id) values(2); #插入指定列的数据
Query OK, 1 row affected (0.09 sec)

MariaDB [zxl]> select * from M33;
---- ----------
| id | name |
---- ----------
| 1 | zhangsan |
| 2 | NULL |
---- ----------
2 rows in set (0.00 sec)

MariaDB [zxl]> insert into M33 (name) values (‘lisi‘); #主键不能为空且唯一,所以这样插入数据不成功
ERROR 1364 (HY000): Field ‘id‘ doesn‘t have a default value

MariaDB [zxl]> select * from M33; #删除数据前的表
---- ----------
| id | name |
---- ----------
| 1 | zhangsan |
| 2 | NULL |
---- ----------
2 rows in set (0.00 sec)

MariaDB [zxl]> delete from M33 where id=2; #删除指定的行数据,如果没有where的限制条件,那么表的内容将全部清空
Query OK, 1 row affected (0.02 sec)

MariaDB [zxl]> select * from M33; #删除后数据的显示
---- ----------
| id | name |
---- ----------
| 1 | zhangsan |
---- ----------
1 row in set (0.00 sec)

MariaDB [zxl]> update M33 set name=‘lisi‘ where id=1; #修改指定行的指定列的内容
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [zxl]> select * from M33;
---- ------
| id | name |
---- ------
| 1 | lisi |
---- ------
1 row in set (0.00 sec)



简单函数的运用:
MariaDB [hellodb]> select avg(age) age from students; #平均age的函数,avg(age) age中括号外的age是别名,完整的写法为avg(age) as age ,其中这个as可以省略
---------
| age |
---------
| 28.2000 |
---------
1 row in set (0.00 sec)
MariaDB [hellodb]> select gender, avg(age) age from students group by gender; #分组求平均
-------- ---------
| gender | age |
-------- ---------
| F | 26.7000 |
| M | 29.2000 |
-------- ---------
2 rows in set (0.00 sec)
MariaDB [hellodb]> select gender, avg(age) age from students where age>20 group by gender; #在where限制条件后再求分组的平均
-------- ---------
| gender | age |
-------- ---------
| F | 30.1429 |
| M | 36.2222 |
-------- ---------
2 rows in set (0.00 sec)
说明:除了avg还有abs求绝对值 max最大值min最小值 sum和等的函数,其用法一致
表连接:
MariaDB [hellodb]> desc students;
----------- --------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
----------- --------------------- ------ ----- --------- ----------------
| StuID | int(10) unsigned | NO | PRI | NULL | auto_increment |
| Name | varchar(50) | NO | | NULL | |
| Age | tinyint(3) unsigned | NO | | NULL | |
| phone | char(11) | YES | | NULL | |
| Gender | enum(‘F‘,‘M‘) | NO | | NULL | |
| ClassID | tinyint(3) unsigned | YES | | NULL | |
| TeacherID | int(10) unsigned | YES | | NULL | |
----------- --------------------- ------ ----- --------- ----------------
7 rows in set (0.04 sec)

MariaDB [hellodb]> desc classes;
---------- ---------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
---------- ---------------------- ------ ----- --------- ----------------
| ClassID | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
| Class | varchar(100) | YES | | NULL | |
| NumOfStu | smallint(5) unsigned | YES | | NULL | |
---------- ---------------------- ------ ----- --------- ----------------
3 rows in set (0.00 sec)


MariaDB [hellodb]> select students.name ,classes.class from students join classes on students.classid=classes.classid;
---------------- ----------------
| name | class |
---------------- ----------------
| Hou Yi | Emei Pai |
| Ya Se | Shaolin Pai |
| An Qila | Emei Pai |
| Da Ji | Wudang Pai |
| Sun Shangxiang | QingCheng Pai |
| Huang Zhong | Riyue Shenjiao |
| Liu Bei | QingCheng Pai |
| Guan Yu | Ming Jiao |
| Zhang Fei | Lianshan Pai |
| Di Renjie | QingCheng Pai |
| Li Yuanfang | Lianshan Pai |
| Lan Lingwang | Shaolin Pai |
| Wang Zhaojun | Emei Pai |
| Bai Qi | QingCheng Pai |
| A Ke | Wudang Pai |
| Cai Wenji | Shaolin Pai |
| Lv Bu | Wudang Pai |
| Diao Chan | Ming Jiao |
| Gong Sunli | Lianshan Pai |
| Ming Shiyin | Ming Jiao |
| Dun Shan | Lianshan Pai |
| Zhou Yu | Shaolin Pai |
| Mi Yue | Wudang Pai |
---------------- ----------------
23 rows in set (0.00 sec)
#上边是两表连接
MariaDB [hellodb]> desc classes;
---------- ---------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
---------- ---------------------- ------ ----- --------- ----------------
| ClassID | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
| Class | varchar(100) | YES | | NULL | |
| NumOfStu | smallint(5) unsigned | YES | | NULL | |
---------- ---------------------- ------ ----- --------- ----------------
3 rows in set (0.03 sec)
MariaDB [hellodb]> desc courses;
---------- ---------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
---------- ---------------------- ------ ----- --------- ----------------
| CourseID | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| Course | varchar(100) | NO | | NULL | |
---------- ---------------------- ------ ----- --------- ----------------
2 rows in set (0.00 sec)

MariaDB [hellodb]> desc students;
----------- --------------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
----------- --------------------- ------ ----- --------- ----------------
| StuID | int(10) unsigned | NO | PRI | NULL | auto_increment |
| Name | varchar(50) | NO | | NULL | |
| Age | tinyint(3) unsigned | NO | | NULL | |
| phone | char(11) | YES | | NULL | |
| Gender | enum(‘F‘,‘M‘) | NO | | NULL | |
| ClassID | tinyint(3) unsigned | YES | | NULL | |
| TeacherID | int(10) unsigned | YES | | NULL | |
----------- --------------------- ------ ----- --------- ----------------
7 rows in set (0.01 sec)

MariaDB [hellodb]> select s.name as student_name, co.course as course from students s join coc c on s.classid=c.classid join courses co on c.courseid=co.courseid;
---------------- ----------------------
| student_name | course |
---------------- ----------------------
| Hou Yi | Kuihua Baodian |
| Hou Yi | Dugu Jiujian |
| Ya Se | Kuihua Baodian |
| Ya Se | Xixing Dafa |
| An Qila | Kuihua Baodian |
| An Qila | Dugu Jiujian |
| Da Ji | Xixing Dafa |
| Da Ji | Kuihua Baodian |
| Sun Shangxiang | Hama Gong |
| Sun Shangxiang | Dagou Bangfa |
| Huang Zhong | Hama Gong |
| Liu Bei | Hama Gong |
| Liu Bei | Dagou Bangfa |
| Guan Yu | Taiji Quan |
| Guan Yu | XiangLong Shibazhang |
| Zhang Fei | XiangLong Shibazhang |
| Zhang Fei | Taiji Quan |
| Di Renjie | Hama Gong |
| Di Renjie | Dagou Bangfa |
| Li Yuanfang | XiangLong Shibazhang |
| Li Yuanfang | Taiji Quan |
| Lan Lingwang | Kuihua Baodian |
| Lan Lingwang | Xixing Dafa |
| Wang Zhaojun | Kuihua Baodian |
| Wang Zhaojun | Dugu Jiujian |
| Bai Qi | Hama Gong |
| Bai Qi | Dagou Bangfa |
| A Ke | Xixing Dafa |
| A Ke | Kuihua Baodian |
| Cai Wenji | Kuihua Baodian |
| Cai Wenji | Xixing Dafa |
| Lv Bu | Xixing Dafa |
| Lv Bu | Kuihua Baodian |
| Diao Chan | Taiji Quan |
| Diao Chan | XiangLong Shibazhang |
| Gong Sunli | XiangLong Shibazhang |
| Gong Sunli | Taiji Quan |
| Ming Shiyin | Taiji Quan |
| Ming Shiyin | XiangLong Shibazhang |
| Dun Shan | XiangLong Shibazhang |
| Dun Shan | Taiji Quan |
| Zhou Yu | Kuihua Baodian |
| Zhou Yu | Xixing Dafa |
| Mi Yue | Xixing Dafa |
| Mi Yue | Kuihua Baodian |
---------------- ----------------------
45 rows in set (0.00 sec)

#三表连接



mysql> select students.name ,teachers.name from students left join teas on teachers.tid=students.teacherid;
---------------- ---------------
| name | name |
---------------- ---------------
| Hou Yi | Wu Zetian |
| Ya Se | NULL |
| An Qila | NULL |
| Da Ji | Cheng Jisihan |
| Sun Shangxiang | Liu Bang |
| Huang Zhong | NULL |
| Liu Bei | NULL |
| Guan Yu | NULL |
| Zhang Fei | NULL |
| Di Renjie | NULL |
| Li Yuanfang | NULL |
| Lan Lingwang | NULL |
| Wang Zhaojun | NULL |
| Bai Qi | NULL |
| A Ke | NULL |
| Cai Wenji | NULL |
| Lv Bu | NULL |
| Diao Chan | NULL |
| Gong Sunli | NULL |
| Ming Shiyin | NULL |
| Dun Shan | NULL |
| Zhou Yu | NULL |
| Mi Yue | NULL |
| Kai | NULL |
| Sun Wukong | NULL |
---------------- ---------------
25 rows in set (0.00 sec)

说明:左连接就是以左边的表为主体,其显示匹配的信息和为匹配的信息都会显示




 视图:
mysql> create view view_name_age as select name,age from students; #视图的创建
mysql> select * from view_naem_age; #查询视图
mysql> create view view_name as select students.name sname,teachers.name from students join teachers on students.teacherid=teachers.tid; #复杂视图的创建时要注意列头名字不能一样,建议用别名来创建复杂视图
mysql> drop view view_name; #删除视图
触发器:
触发器解释:当一个事件发生时伴随着另一个事件的发生,具体的伴随事件发生情况要根据自己定义的策略
mysql> create trigger trigger_student after insert on student_info for each row update student_count set student_count=student_count 1;
Query OK, 0 rows affected (0.01 sec)
说明:触发器的策略定制 当在student_info中插入数据时student_count会自动增加一
mysql> select * from student_info;
Empty set (0.00 sec)
mysql> select * from student_count;
---------------
| student_count |
---------------
| 0 |
---------------
1 row in set (0.00 sec)
mysql> desc student_info;
---------- -------------- ------ ----- --------- ----------------
| Field | Type | Null | Key | Default | Extra |
---------- -------------- ------ ----- --------- ----------------
| stu_id | int(11) | NO | PRI | NULL | auto_increment |
| stu_name | varchar(255) | YES | | NULL | |
---------- -------------- ------ ----- --------- ----------------
2 rows in set (0.00 sec)
mysql> insert into student_info values(1,‘zhang‘);
Query OK, 1 row affected (0.00 sec)
mysql> select * from student_info;
-------- ----------
| stu_id | stu_name |
-------- ----------
| 1 | zhang |
-------- ----------
1 row in set (0.00 sec)
mysql> select * from student_count;
---------------
| student_count |
---------------
| 1 |
---------------
1 row in set (0.00 sec)
触发器的查询:
mysql> show triggersG;
触发器的删除:
mysql> drop trigger triggername;
数据库账户的增加及授权:
账号的查询:
mysql> select user,host,password from mysql.user;
------ ----------------------- -------------------------------------------
| user | host | password |
------ ----------------------- -------------------------------------------
| root | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | 127.0.0.1 | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | 192.168.127.7 | *128977E278358FF80A246B5046F51043A2B1FCED |
------ ----------------------- -------------------------------------------
6 rows in set (0.00 sec)
说明:一个账号是user和host一起才是一个完整的账号,而host中的ip是客户端的ip地址,同样的当客户端连接服务端时的ip地址是服务端的ip


账号的删除:
mysql> drop user [email protected]‘192.168.127.7‘;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host, password from mysql.user;
------ ----------------------- -------------------------------------------
| user | host | password |
------ ----------------------- -------------------------------------------
| root | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | 127.0.0.1 | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
------ ----------------------- -------------------------------------------
5 rows in set (0.00 sec)


账号的创建:

mysql> create user [email protected]‘192.168.127.7‘ identified by ‘centos‘;
Query OK, 0 rows affected (0.00 sec)


mysql> select user,host, password from mysql.user;
------ ----------------------- -------------------------------------------
| user | host | password |
------ ----------------------- -------------------------------------------
| root | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | 127.0.0.1 | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| | localhost.localdomain | *5D83A6402DF44A7D8EC2B8861B19F8A2F4F3EA2F |
| root | 192.168.127.7 | *128977E278358FF80A246B5046F51043A2B1FCED |
------ ----------------------- -------------------------------------------

6 rows in set (0.00 sec)

账号连接:
[[email protected] ~]# mysql -uroot -pcentos -h 192.168.127.142
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]>

说明:此命令是在另一个终端上的,非服务器端。这个ip是服务端的ip地址,此终端的ip地址为192.168.127.7(客户端的ip)-p中的centos是密码

账号的授权:
MySQL [(none)]> show databases;
--------------------
| Database |
--------------------
| information_schema |
| test |
--------------------
2 rows in set (0.00 sec)

说明:这个是新增账号的库的显示

mysql> show databases;
--------------------
| Database |
--------------------
| information_schema |
| hellodb |
| mysql |
| test |
--------------------
4 rows in set (0.00 sec)

说明: 这个是管理员连接同一个数据库的库的显示

授权:
mysql> grant all on hellodb.* to [email protected]‘192.168.127.7‘;
Query OK, 0 rows affected (0.00 sec)
MySQL [(none)]> show databases;
--------------------
| Database |
--------------------
| information_schema |
| hellodb |
| test |
--------------------
3 rows in set (0.00 sec)

说明:只有管理员才可以授权,本次授权是all(insert,select.....)库文件是hellodb下的所有的表,当然了也可以部分授权。


部分授权:
mysql> grant select(stuid,name) on hellodb.student to [email protected]‘192.168.127.7‘;
说明:授权库某个表的select的部分权限

查看授权:

mysql> show grants for [email protected]‘192.168.127.7‘;
-----------------------------------------------------------------------------------------------------------------
| Grants for [email protected] |
-----------------------------------------------------------------------------------------------------------------
| GRANT USAGE ON *.* TO ‘root‘@‘192.168.127.7‘ IDENTIFIED BY PASSWORD ‘*128977E278358FF80A246B5046F51043A2B1FCED‘ |
| GRANT ALL PRIVILEGES ON `hellodb`.* TO ‘root‘@‘192.168.127.7‘ |
-----------------------------------------------------------------------------------------------------------------
2 rows in set (0.00 sec)

删除授权:

mysql> revoke all on hellodb.* from [email protected]‘192.168.127.7‘;
Query OK, 0 rows affected (0.00 sec)
约束:
新增非空约束:

mysql> create table t1(id int(10) not null,name varchar(20)); #约束创建(在建表时)

mysql> insert into t1 values(null,‘zhang‘);
ERROR 1048 (23000): Column ‘id‘ cannot be null

mysql> alter table t1 modify name varchar(20) not null; #建表后增加约束
mysql> insert into t1 values(1,null);
Query OK, 1 row affected (0.00 sec)
mysql> alter table t1 modify name varchar(20) not null;
Query OK, 1 row affected, 1 warning (0.10 sec)
Records: 1 Duplicates: 0 Warnings: 1

mysql> insert into t1 values(1,null);
ERROR 1048 (23000): Column ‘name‘ cannot be null

删除约束:删除约束就是在新增约束时不加约束条件在重新定义一遍

唯一约束:主键的设置
 
————————————————
版权声明:本文为CSDN博主「root_oo7」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/root__oo7/article/details/82817501