標籤:資料庫
增:
create database database_name;
create table table_name(
id int not null AuTo_increment
zd1 char(5) not null
zd2 char(8) not null
primary key id
);
alter table table_name add 欄位;
insert into table_name(欄位1,欄位2.。。。)values(‘xxx‘,‘xxx‘...);
刪:
delete from table_name where between n1 and n2;
drop table table_name;
alter table table_name drop 欄位;
查:
show databases;
show tables;
show create table_name;
desc table_name;
select 欄位 from table_name where 條件;
select 欄位,欄位 from table_name order by id desc limit n;
改:
alter table old_table_name rename table_name;
updata table_name set 欄位="xxx" where 條件;
alter table table_name rename 舊欄位 新欄位;
alter table table_name change 舊欄位 新欄位 字元類型;
授權:
grant select,insert,update,delete(or all privileges) on 資料庫.資料表 to 使用者名稱@"IP" identified by "密碼" (with grant option ----可以給其他使用者授權);
FLUSH PRIVILEGES;----儲存更改並立即生效
mysql筆記之最基本