当前位置:网站首页>MySQL basics [naming convention]
MySQL basics [naming convention]
2022-07-30 08:03:00 【The brain can't be empty】
Directory
First, the naming problem of MySQL under different systems
1.Linux
- Database name and table name are strictly case-sensitive;
- Table aliases are strictly case-sensitive;
- Column names and column aliases are case-insensitive in all cases;
- Variable names are also strictly case-sensitive;
2. Windows
- All are case insensitive
Second, a unified writing standard is recommended
The database name, table name, table alias, field name, field alias, etc. are all lowercase. When defining databases, tables, and columns, all use lowercase letters and underscores, and do not use any capital letters.
SQL keywords, function names, bind variables, etc. are capitalized
Third, naming rules
- Database and table names cannot exceed 30 characters, and variable names are limited to 29
- Must only contain A–Z, a–z, 0–9, _total63 characters
- Database name, table name, field name and other object names do not contain spaces
- In the same MySQL software, databases cannot have the same name; in the same database, tables cannot have the same name; in the same table, fields cannot have the same name
- You must ensure that your fields do not conflict with reserved words, database systems, or common methods.If you insist, use ` (emphasis) in SQL statements
- Keep field names and types consistent, be sure to consistent when naming fields and assigning data types to them.If the data type is integer in one table, don't change it to character in another table
Example:
#The following two sentences are the same, not case sensitiveshow databases;SHOW DATABASES;#create form#create table student info(...); #The table name is wrong because there are spaces in the table namecreate table student_info(...);#Where order uses ``floating number, because order and predefined identifiers such as system keywords or system function names have the same nameCREATE TABLE `order`();#When making an alias, as can be omittedselect id as "ID", `name` as "name" from t_stu;#If there is no space in the field alias, you can omit ""select id as id, `name` asNamefrom t_stu;#Error, if there are spaces in the field alias, you cannot omit ""select id as id, `name` asNamefrom t_stu; 边栏推荐
- Go 结合Gin导出Mysql数据到Excel表格
- assert
- The usage of window.open(), js opens a new form
- What new materials are used in the large aircraft C919?
- ETL为什么经常变成ELT甚至LET?
- Rodrigues: vector representation of rotation matrices
- 识别“数据陷阱”,发现数据的可疑之处
- Electron日常学习笔记
- The first artificial intelligence safety competition officially launched
- export , export default, import complete usage
猜你喜欢

PXE efficient mass network capacity

What are the access modifiers, declaration modifiers, and keywords in C#?Literacy articles

识别“数据陷阱”,发现数据的可疑之处

How does Redis prevent oversold and inventory deduction operations?

Linx common directory & file management commands & VI editor usage introduction

Redis download and installation

New breakthrough in artificial muscle smart materials

Go 使用mencached缓存

Playing script killing with AI: actually more involved than me

Distance calculation from space vertex to straight line and its source code
随机推荐
New breakthrough in artificial muscle smart materials
Universal js time date format conversion
(GGG)JWT
Go 使用 freecache 缓存
学生成绩管理系统(C语言)
MySQL什么时候用表锁,什么时候用行锁?
STL源码剖析:class template explicit specialization代码测试和理解
Graphical relational database design ideas, this is too vivid
go : go-redis 基础操作
@Bean 与 @Component 用在同一个类上,会怎样?
Local Implicit Grid Representations for 3D Scenes详解
Electron之初出茅庐——搭建环境并运行第一个程序
“AI教练”请进家,家庭智能健身蓬勃发展
什么是微服务?
Equation Derivation Proof of Vector Triple Product
What are the access modifiers, declaration modifiers, and keywords in C#?Literacy articles
Ali: How many methods are there for multi-threaded sequential operation?
The newcomer deleted data by mistake, and the team leader skillfully used MySQL master-slave replication to delay the recovery of losses
RAID disk array
DHCP principle and configuration