您好,登錄后才能下訂單哦!
今天小編就為大家?guī)硪黄榻Bmysql和mysqldb常用語句的文章。小編覺得挺實(shí)用的,為此分享給大家做個(gè)參考。一起跟隨小編過來看看吧。
create database if not exists hidb; #創(chuàng)建庫,如果此庫不存在
show warnings; #查看db最近一次的告警
alter database hidb character set 'utf-8'; #設(shè)置數(shù)據(jù)庫字符集
drop database testdb; #刪除庫
show databases like '%db'; #查詢以db結(jié)尾的數(shù)據(jù)庫信息
help show databases; #幫助
create table tbl2 (id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE KEY,name VARCHAR(60) NOT NULL); #創(chuàng)建表結(jié)構(gòu)
create table tbl2 (id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT ,name VARCHAR(60) NOT NULL,UNIQUE KEY(id,name)); #創(chuàng)建表結(jié)構(gòu)
help desc; #幫助
describe city; #查詢表結(jié)構(gòu)
DESC tbl2; #查詢表結(jié)構(gòu)
show engines; #查看支持的引擎
show table status; #查看所有表狀態(tài)信息
show table status like 'tablename'\G; #查看單表狀態(tài)信息
show table status where name like 'table'; #查看以table開頭的表
show table status where Engine='MyISAM'; #查詢引擎為MyISAM的表狀態(tài)
alter table tbl3 ADD gender ENUM('F','M'); #修改表結(jié)構(gòu),新增枚舉字段
alter table tbl3 CHANGE id stuid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; #修改字段名 id 為 stuid
alter table tbl3 ADD INDEX (name); #創(chuàng)建索引
show INDEXES from tbl3; #查看表中的所有索引
alter table tbl3 drop index id; #刪除id字段的索引
alter table tbl3 drop primary key id; #刪除id字段的主鍵
create table tbl4 like mysql.user; #創(chuàng)建tbl4表,從mysql.user復(fù)制表結(jié)構(gòu)
create table tbl5 select host,user,passwd from mysql.user; #查詢mysql.user表中的字段及內(nèi)容,放到新創(chuàng)建的表中
create index indexname on tabl5(id); #創(chuàng)建索引
以上就是mysql和mysqldb常用語句的詳細(xì)內(nèi)容了,看完之后是否有所收獲呢?如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。