Home > Database > Mysql Tutorial > What are the syntax specifications of mysql?

What are the syntax specifications of mysql?

王林
Release: 2023-06-03 10:37:03
forward
1824 people have browsed it

1. The sql syntax of mysql is not case-sensitive.

2. When naming, try to use 26 English letters in upper and lower case, numbers 0-9, and underlines.

Do not use other symbols.

3. It is recommended not to use mysql keywords as table names, field names, etc.

If used accidentally, please use ` (floating sign) in the SQL statement.

4. There should be no spaces between database and table names, field names and other object names.

In the same mysql software, the database cannot have the same name. In the same database, tables cannot have the same name, and in the same table, fields cannot have the same name.

Example

#以下两句是一样的,不区分大小写
show databases;
SHOW DATABASES;
 
#创建表格
#create table student info(...); #表名错误,因为表名有空格
create table student_info(...);
 
#其中name使用``飘号,因为name和系统关键字或系统函数名等预定义标识符重名了。
CREATE TABLE t_stu(
    id INT,
    `name` VARCHAR(20)
);
 
select id as "编号", `name` as "姓名" from t_stu; #起别名时,as都可以省略
select id as 编号, `name` as 姓名 from t_stu; #如果字段别名中没有空格,那么可以省略""
select id as 编 号, `name` as 姓 名 from t_stu; #错误,如果字段别名中有空格,那么不能省略""
Copy after login

The above is the detailed content of What are the syntax specifications of mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template