2016-02-16 68 views
1

是否有MySQL的內置幫助文檔?例如,如果我忘了語法從表中刪除行,我可以做內置MySQL幫助文檔

mysql> DELETE <TAB> 

mysql> mysqldoc DELETE 

其中,後者類似於Python的pydoc命令?

回答

0

你可以用help做到這一點:

mysql> help DELETE 
Name: 'DELETE' 
Description: 
Syntax: 
Single-table syntax: 

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name 
    [WHERE where_condition] 
    [ORDER BY ...] 
    [LIMIT row_count] 

Multiple-table syntax: 

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] 
    tbl_name[.*] [, tbl_name[.*]] ... 
    FROM table_references 
    [WHERE where_condition] 

Or: 

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] 
    FROM tbl_name[.*] [, tbl_name[.*]] ... 
    USING table_references 
    [WHERE where_condition] 

For the single-table syntax, the DELETE statement deletes rows from 
tbl_name and returns a count of the number of deleted rows. This count 
can be obtained by calling the ROW_COUNT() function (see 
http://dev.mysql.com/doc/refman/5.5/en/information-functions.html). The 
WHERE clause, if given, specifies the conditions that identify which 
rows to delete. With no WHERE clause, all rows are deleted. If the 
ORDER BY clause is specified, the rows are deleted in the order that is 
specified. The LIMIT clause places a limit on the number of rows that 
can be deleted. 

For the multiple-table syntax, DELETE deletes from each tbl_name the 
rows that satisfy the conditions. In this case, ORDER BY and LIMIT 
cannot be used. 

where_condition is an expression that evaluates to true for each row to 
be deleted. It is specified as described in 
http://dev.mysql.com/doc/refman/5.5/en/select.html. 

Currently, you cannot delete from a table and select from the same 
table in a subquery. 

You need the DELETE privilege on a table to delete rows from it. You 
need only the SELECT privilege for any columns that are only read, such 
as those named in the WHERE clause. 

As stated, a DELETE statement with no WHERE clause deletes all rows. A 
faster way to do this, when you do not need to know the number of 
deleted rows, is to use TRUNCATE TABLE. However, within a transaction 
or if you have a lock on the table, TRUNCATE TABLE cannot be used 
whereas DELETE can. See [HELP TRUNCATE TABLE], and [HELP LOCK]. 

URL: http://dev.mysql.com/doc/refman/5.5/en/delete.html