Hiểu một số lệnh client MySQL.
MySQL gửi mọi câu lệnh SQL user phát hành đến server để thực thi. Cũng có tập lệnh mà mysql tự thông dịch.
Lấy danh sách lệnh
Gõ lệnh sau tại dấu nhắc:
mysql> help
Kết quả
List of all MySQL commands: ? (\?) Synonym for `help'. clear (\c) Clear current input statement. connect (\r) Reconnect to server. Optional args: db, host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute SQL script file. Takes file name as argument. status (\s) Get status information from server. system (\!) Execute system shell command. tee (\T) Set outfile [to_outfile]. Append everything into outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Needed for binlog with multi-byte charsets. warnings (\W) Show warnings after every statement.
Nếu mysql gọi với --binary-mode, tất cả lệnh client bị vô hiệu trừ charset và delimiter ở chế độ non-interactive (input piped hoặc loaded qua source).
Mỗi lệnh có dạng dài và ngắn.
Dạng dài
Dạng dài không phân biệt chữ hoa/thường; dạng ngắn phân biệt. Dạng dài có thể theo sau dấu chấm phẩy tùy chọn; dạng ngắn không được theo sau bởi gì.
Dạng ngắn
Dùng dạng ngắn trong comment nhiều dòng /* ... */ không hỗ trợ. Dạng ngắn hoạt động trong comment một dòng phiên bản /*! ... */ và comment optimizer-hint /*+ ... */. Chúng được lưu trong định nghĩa đối tượng.