1.1
create database Market;
1.2
mysql> create table customers (
-> c_num int(11) primary key not null auto_increment,
-> c_name varchar(50),
-> c_contact varchar(50),
-> c_city varchar(50),
-> c_birth datetime not null
-> );
1.3
mysql> alter table customers drop c_contact;
mysql> alter table customers add c_contact varchar(50) after c_birth;
1.4
alter table customers modify c_name varchar(70);
1.5
alter table customers change c_contact c_phone varchar(50);
1.6
alter table customers add c_gender char(1);
1.7
rename table customers to customers_info;
1.8
mysql> alter table customers_info drop c_city;
1.9
mysql> show engines;//查看支持的存储引擎
show variables like '%storage_engine%'; //查看默认的存储引擎
ALTER table customers_info engine=MyISAM;
结果:
mysql> desc customers_info;
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| c_num | int(11) | NO | PRI | NULL | auto_increment |
| c_name | varchar(70) | YES | | NULL | |
| c_birth | datetime | NO | | NULL | |
| c_phone | varchar(50) | YES | | NULL | |
| c_gender | char(1) | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
文章来源:https://www.toymoban.com/news/detail-536319.html
mysql> create table orders (
-> o_num int(11) primary key not null auto_increment unique,
-> o_date date,
-> o_id int(11),
->foreign key(o_id) references customers_info(c_num)
-> );
//注意,在上题中更改了引擎,添加外键不成功的原因可能是引擎的原因
2.2
show create table orders;//先查看外键名
alter table orders drop foreign key orders_ibfk_1;//再删除外键
mysql> drop table customers_info;//再删除表customers_info
文章来源地址https://www.toymoban.com/news/detail-536319.html
3.1
grant select,insert on team.player to account1@'localhost' identified by 'Oldpwd111.';
grant update(info) on team.player to account1@'localhost' identifieed by 'Oldpwd111.';
3,2
mysql> SET GLOBAL validate_password_policy='LOW';
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_length=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_number_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_length=0;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user account1@'localhost' identified by 'newpwd2';
Query OK, 0 rows affected (0.00 sec)
//修改权限限制后用户account1可以设置简单密码
3.3
mysql> flush privileges;
//刷新权限表
3.4
SHOW GRANTS FOR 'account1'@'localhost';//查看权限
GRANT USAGE ON *.* TO 'account1'@'localhost' |
| GRANT SELECT, INSERT, UPDATE (info) ON `team`.`player` TO 'account1'@'localhost' |
3.5
revoke all on team.player from account1@'localhost';//撤权
3.6
drop user account1;
到了这里,关于MySQL作业的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!