mysql 串連命令 表管理 ,複製表,暫存資料表,字串屬性,設定語句間的分隔字元

來源:互聯網
上載者:User

標籤:

串連和斷開
串連
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 串連命令 表管理 ,複製表,暫存資料表,字串屬性,設定語句間的分隔字元

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.