`
renzhelife
  • 浏览: 664460 次
文章分类
社区版块
存档分类
最新评论

MySQL schema命名规则

 
阅读更多

/*****************by garcon1986************************************************************/

通用规则:

整 个数据库里的名字都尽量使用小写。这样能消除由于大小写( case-sensitivity )带来 的错误。 Mysql 默认区分大小写。 使 用下划线断开名字,名字中不能 使用空格。 名字中尽量不要 使 用数字。 名字中尽量不要 使用" .", 这 样能避免在查询时出错 名字中不能使用保留字。 尽 量使名字简单。

数据库名:

一 般情况下,使用项目名称作为数据库的名字。 数据库名字前加所有者的名字作为前缀。

表名:

可 以使用缩略词作为前缀 如:" hr_”, "mkt_”,非别代表了human resource, marketing部门。 不要使用通用的前缀 如:" tbl_”, "db_”,这样 没有实际意义,反而看起来更麻烦。 表名尽量简短,准确。 关 于表名的单复数,根据个人习惯决定,没有对错

列名:

主 键一般 是" 表名 _id”。 外 键的列名和另一个表的主键名一致

如: create table manager (manager_id int(11) primary key );

create table employee(

employee_id int(11) primary key,

manager_id int(11),

FOREIGN KEY (manager_id) REFERENCES manager(manager_id) ON DELETE CASCADE)

列 名以 3 个字母的表格缩写为前缀

日 期列以" date_” 为前缀

Boolean 类 型列以" is_” 为前缀

引用:

MySQL database identifiers that can be named include databases, tables, and columns. The MySQL documentation contains extensive information about naming conventions. Here are some of the naming conventions that you must use:

· All identifier names must be from 1 to 64 characters long, except for aliases, which can be 255 characters long.

· Database names must be unique. For each user within a database, names of database objects must be unique across all users (for example, if a database contains a department table created by user A, no other user can create a department table in the same database).

Note: MySQL does not support schemas. Consequently, tables are automatically visible to all users who have appropriate privileges. Column names and index names must be unique within a table.

· Database names can use any character that is allowed in a directory name except for periods and backward and forward slashes.

· Table names can use any character that is allowed in a filename except for periods and forward slashes.

· Column and alias names allow all characters.

· A name cannot be a MySQL reserved word unless the name is enclosed in quotation marks. See the MySQL documentation for more information about reserved words.

· Embedded spaces and other special characters are not permitted unless the name is enclosed in quotation marks.

· Embedded quotation marks are not permitted.

· Case sensitivity is set when a server is installed. By default, the names of database objects are case sensitive on UNIX and not case sensitive on Windows. For example, the names CUSTOMER and customer are different on a case-sensitive server.

Note: By default, column and table names are not quoted. If you are using the SAS Table Server LIBNAME engine, you can quote the table and column names by using the LIBNAME or data set options PRESERVE_COL_NAMES= and PRESERVE_TAB_NAMES=.

分享到:
评论

相关推荐

    专业级的MySQL开发设计规范及SQL编写规范

    命名规范的对象是指数据库SCHEMA、表TABLE、索引INDEX、约束CONSTRAINTS等的命名约定 数据库对象命名原则 命名使用具有意义的英文词汇,词汇中间以下划线分隔 命名只能使用英文字母、数字、下划线 避免用MySQL的...

    MySQL5.1性能调优与架构设计.mobi

    9.3 规范的对象命名 9.4 小结 第10章 MySQL Server性能优化 10.0 引言 10.1 MySQL安装优化 10.2 MySQL日志设置优化 10.3 Query Cache优化 10.4 MySQL Server其他常用优化 10.5 小结 第11章 常用存储引擎...

    mysql数据库的基本操作语法

    MySQL中约束保存在information_schema数据库的table_constraints中,可以通过该表查询约束信息; 约束主要完成对数据的检验,保证数据库数据的完整性;如果有相互依赖数据,保证该数据不被删除。 常用五类约束: ...

    graphql-starter

    GraphQL入门这是规则怎么怎么跑 npm install或者 yarn install使用数据库信息编辑start.sh MYSQL_DATABASE=<db> MYSQL_HOST=<host> MYSQL_PASSWORD=<password> MYSQL_PORT=<mysql> MYSQL_USER=<user> PORT=<app> ...

    送强力打狗棒,文末领取

    遇到无法读数据库情况,例如拦截了INFORMATION_SCHEMA,可以配合触发内置白名单的方法,直接放行。 MySQL #单行注释 -- 单行注释(特别注意,-- 后有个空格!!!) /*多行注释*/ MS SQL Server -- 单行注释 /*...

    springmybatis

    在User.xml 的配置文件中,mapper namespace="com.yihaomen.mybatis.inter.IUserOperation" ,命名空间非常重要,不能有错,必须与我们定义的package 和 接口一致。 运行这个测试程序,就可以看到结果了。 除非...

    JdbcTemplateTool.zip

    自动根据数据库的列将下划线转为驼峰命名规则映射类的属性.@Test public void testList(){  JdbcTemplateTool jtt = super.applicationContext.getBean("jdbcTemplateTool",JdbcTemplateTool.class);  List...

    asp.net知识库

    Oracle编程的编码规范及命名规则 Oracle数据库字典介绍 0RACLE的字段类型 事务 CMT DEMO(容器管理事务演示) 事务隔离性的一些基础知识 在组件之间实现事务和异步提交事务(NET2.0) 其它 在.NET访问MySql数据库时的...

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

    Mysql 甲骨文 是个开源的数据库server,可运行在多种平台, 特点是响应速度特别快,主要面向中小企业 中小型企业 PostgreSQL 号称“世界上最先进的开源数据库“,可以运行在多种平台下,是tb级数据库,而且性能也很...

Global site tag (gtag.js) - Google Analytics