標籤:
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面試(轉載)