標籤:
1.建立資料庫
create database school;
2.使用資料庫
Use school;
3.建立使用者
create user [email protected] identified by ‘jame‘;
4.授權使用者(注意這裡是用了*哦,可以自己講school也替換成*號)
grant select,update,insert,create on school.* to [email protected] identified by ‘j ame‘;
5.取消授權(現在明白為啥直接敲privilege 沒用了吧?)
revoke select,update,insert,create on school.* from [email protected];
6.建立表
create table students(s_name varchar(10) not null,age int(3),sex char(1),heig ht int,s_no varchar(20) not null,primary key(s_no));
7.修改表名
alter table students rename to student;
8.修改列
alter table students change s_name name varchar(20) not null;
9.增加列
alter table student add class varchar(20);
10.刪除列
alter table student drop column class;
11.刪除表
drop table student;
12.刪除使用者
drop user jame;
13.刪除資料庫
drop database school;
查看資料庫的表結構方法 desc students; 或者 describe students; 另:mysql使用者進入控制台後無法切換使用者,只能先退出終端,再重新串連。
mysql 建庫建表建使用者