1. 程式人生 > >mysql相關執行語句

mysql相關執行語句

W3school教程
http://www.w3school.com.cn/sql/sql_update.asp

建立資料庫語句
create database database_name;

刪除資料庫語句
drop database database_name;

建立表語句
use database_name;
create table table_name(nid int,name varchar(20));

刪除表語句
drop table table_name;

刪除表中的行(按指定的內容刪除)
delete from table_name where 欄位="*****";

清空表內容(一次性全部清空)

truncate table table_name

插入資料行
insert into tab21(nid,name) values(1,"kevin1");

修改資料
update table_name set 欄位="old_value" where 欄位="new_value";

新建使用者
create user [email protected]_address identified by "password";

對指定使用者進行授權(許可權根據需求進行授權:select,insert)
grant select on databases.table_name to [email protected]

_address

刪除使用者
drop user [email protected]_address;

自增

create table table_name(

  nid int not null auto_increment primary key,#必須要設定為主鍵,不然會報錯

  num int

)engine=innode default=utf8;