標籤:
串連和斷開
串連
mysql -h host -u user -p (即,串連的主機、使用者名稱和使用的密碼)。
斷開
輸入QUIT (或\q)隨時退出:
表管理
複製表
注意:create table ... like 語句不複製表的外鍵定義,不複製原表可能使用的data directory 和index directory. 和auto_increment
--建立一張和現有的某張表結構一致的表。
create table new_table like original_table
--把某張的資料插入到複製好的表插入
insert into new_table select * from original_table
insert into new_table(列) select 列 from original_table
--複製一表,把資料也複製過來。
create table new_table select * from original_table
暫存資料表
暫存資料表是與各個資料庫連接相關的,中斷連線自動刪除暫存資料表。
暫存資料表具有的另外一個特性是,暫存資料表可以使用普通表的表名,這樣做的結果是,在暫存資料表的生命週期內,它將屏蔽與之同名的普通表。
建立暫存資料表
create temporary table 新表名 like 目錄表名
刪除暫存資料表
drop temporary table 表名。(temporary關鍵字在這裡,可以避免錯誤的刪除同名的普通表。)
drop table 表名。
改變表的儲存引擎
MyISAM
alter table 表名 engine = InnoDB
查看錶的儲存引擎
select engine from information_schema.`TABLES` where TABLE_NAME=‘表名‘
字串屬性
分為兩類,二進位和非二進位。
非二進位字串的特徵之一:是它們有一個字元集。
查看系統字元集 show character set;
非二進位字串的特徵之二:Collation
查看字元集中的Collation 用: show COLLATION;
也可以只查看特定字元集的Collation例如:show COLLATION like ‘latin1%‘;
delimiter // 設定語句間的分隔字元為//
例
select * from `user`;
select * from `user`
改成
delimiter //
select * from `user`//
select * from `user`
mysql 串連命令 表管理 ,複製表,暫存資料表,字串屬性,設定語句間的分隔字元