mysql的sql_quote_show_create與SHOW CREATE TABLE命令介紹
阿新 • • 發佈:2018-12-10
技術背景: 剛開始學習MySQL時候,有時偷懶,會用SHOW CREATE TABLE 表名\G來複製表建立語句,可是當執行的時候總會因為"表名和列名上有單引號",提示語法錯誤不能執行。問題列表: 1,為什麼會出錯呢? 2,有什麼解決方法?解決問題: 1,分析show create table拷貝的語句出錯原因 1.1 重現過程 1.1.1 建立測試表test,並通過show create table test取得表的建立語句,可見表名,列名都用引號包著。 mysql> create table test( -> id int not null, -> primary key(id) -> ); Query OK, 0 rows affected (0.00 sec) mysql> show create table test \G *************************** 1. row *************************** Table: test Create Table: CREATE TABLE `test`