(ext.) The effect of anti-quotation marks when MySQL creates a table
When you try the Navicat tool to view the current MySQL build table statement, it is found that the table name and field names are quoted in reverse quotation marks.
1234567891011 |
CREATE TABLE `tab_notice_title_tv` (
`i_id` int(11) NOT NULL AUTO_INCREMENT,
`c_opcom_key` varchar(32) DEFAULT NULL,
`c_view_type` int(11) DEFAULT
‘1‘ COMMENT
‘平台类型,1:标清,2:高清‘
,
`c_title` varchar(32) DEFAULT NULL,
`c_status` int(2) DEFAULT
‘0‘
,
`c_creator` varchar(32) DEFAULT
‘‘
,
`c_createtime` varchar(32) DEFAULT NULL,
`c_deleted` int(2) NOT NULL DEFAULT
‘0‘
,
PRIMARY KEY (`i_id`)
) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=gbk;
|
Anti-quotes, usually below the ESC key.
It is a symbol that is introduced to differentiate between MySQL's reserved words and ordinary characters.
For example: Select ' Select ' From ' Test ' WHERE select= ' field value '
In the test table, there is a select field, without the use of anti-quotes, MySQL will treat select as a reserved word resulting in an error, so there is a MySQL reserved word as a field, you must add the anti-quote to distinguish.
Quotation marks are generally used in the value of the field, and if the field value is a character or string, enclose it in quotation marks, such as: select= ' field value '
Tables built without anti-quotes cannot contain mysql reserved words, otherwise an error occurs
The name of the anti-quote, this is actually to prevent when the field is a keyword, with this symbol can not be an error
1234567891011 |
CREATE TABLE `zz_files` (
`
id
` int(11) unsigned NOT NULL AUTO_INCREMENT,
`data_id` int(11) DEFAULT NULL,
`name` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`fileurl` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`ext` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT
‘扩展名‘
,
`cate` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`desc` int(11) DEFAULT NULL,
`c_time` int(11) DEFAULT NULL,
PRIMARY KEY (`
id
`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
|
As with the DESC keyword, this symbol will not go wrong.
(ext.) The effect of anti-quotation marks when MySQL creates a table