mysql面試(轉載)

來源:互聯網
上載者:User

標籤:

mysql面試(轉載)

問題1:你如何確定 MySQL 是否處於運行狀態?

答案: Debian 上運行命令service mysql status,在RedHat 上運行命令service mysqld status。然後看看輸出即可。

問題2:如何開啟或停止 MySQL 服務?

答案:運行命令service mysqld start開啟服務;運行命令service mysqld stop停止服務。

問題3:如何通過 Shell 登入 MySQL?

答案:運行命令mysql -u root -p

問題4:如何列出所有資料庫?答案:運行命令show databases;

問題5: 如何切換到某個資料庫並在上面工作?

答案:運行命令use database_name;進入名為 database_name 的資料庫。

問題6:如何列出某個資料庫內所有表?

答案:在當前資料庫運行命令show tables;

問題7:如何擷取表內所有 Field 對象的名稱和類型?

答案:運行命令describe table_name;

問題8:如何刪除表?

答案:運行命令drop table table_name;

問題9:如何刪除資料庫?

答案:運行命令drop database database-name;

問題10:如何查看錶內所有資料?

答案:運行命令select * from table_name;

問題11:如何從表(比如 oc_users )中擷取一個 field 對象(比如 uid)的所有資料?

答案:運行命令select uid from oc_users;

問題12:假設你有一個名為 ‘xyz’ 的表,它存在多個欄位,如 ‘createtime’ 和 ‘engine’。名為 engine 的欄位由 ‘Memoty’ 和 ‘MyIsam’ 兩種數值組成。如何只列出 ‘createtime’ 和 ‘engine’ 這兩列並且 engine 的值為 ‘MyIsam’?

答案:運行命令select create_time, engine from xyz where engine = ”MyIsam”;

問題13:如何列出表 ‘xrt’ 內 name 域值為 ‘tecmint’,web_address 域值為 ‘tecmint.com’ 的所有資料?

答案:運行命令select * from xrt where name = “tecmint” and web_address = “tecmint.com”;

問題14:如何列出表 ‘xrt’ 內 name 域值不為 ‘tecmint’,web_address 域值為 ‘tecmint.com’ 的所有資料?


問題15:如何知道表內行數?

答案:運行命令select count(*) from table_name;



來自為知筆記(Wiz)

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.