创建Market;
mysql> use Market;
mysql> create table customers(
-> c_num int(11) primary key not null unique auto_increment);
mysql> alter table customers add c_name varchar(50);
mysql> alter table customers add c_city varchar(50);
mysql> alter table customers add c_birth datetime not null;
3
mysql> alter table customers add c_contact varchar(50) after c_birth;
4
mysql> alter table customers modify c_name varchar(70);
5
mysql> alter table customers change c_contact c_phone varchar(50);
6
mysql> alter table customers add c_gender char(1);
7
mysql> alter table customers rename to customers_into;
8
mysql> alter table customers_into drop c_city;
mysql> alter table customers_into engine = MyISAM;
二
mysql> create table orders( c_id int(11) PRIMARY KEY not null UNIQUE auto_increment, o_date date, o_num varchar(50));
修改引擎
mysql> alter table orders engine = MyISAM;
添加外键
mysql> alter table orders add constraint fk_main foreign key(c_id) references customerrs_into(c_num);
drop table orders;
三
1
mysql> grant select,insert on Team.player to account1@‘localhost’ identified by ‘oldpwwd1’;
mysql> grant update (info) on Team.player to ‘account1’@‘localhost’;
2
mysql> set password for account1@localhost = password(‘newpwd2’);
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4
5
6