Home  >  Article  >  Database  >  What are the syntax specifications of mysql?

What are the syntax specifications of mysql?

王林
王林forward
2023-06-03 10:37:031733browse

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; #错误,如果字段别名中有空格,那么不能省略""

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete