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 t
相关文档:
http://www.xiaojb.com/archives/it/mysqlroot.shtml
Method 1:
在/usr/local/mysql/bin/下:
./mysqladmin -u root password ‘new_password’
一般安装时用此方法设置。
Method 2:
在mysql状态下:
mysql>UPDATE user SET password=PASSWORD(’new_password’) WHERE user=’root&rsq ......
选择你的引擎
你能用的数据库引擎取决于MySQL在安装的时候是如何被编译的。要添加一个新的引擎,就必须重新编译MySQL。仅仅为了添加一个特性而编译
应用程序的概念对于Windows的开发人员来说可能很奇怪,但是在Unix世界里,这已经成为了标准。在缺省情况下,MySQL支持三个引
擎:ISAM、MyISAM和HEAP。另外两种 ......
小结:
首先要找到mySql的配置文件
my.cnf
然后要改对地方
[client]和[mysqld]下同时加上default-character-set=utf8
然后记得需要重启MySql.且保证客户端的连接方式也是utf8.
预祝自己新的一年,吉祥如意,心想事成! ......
/***************************by
garcon1986********************************/
1.创建表格时错误: ERROR 1005: Can't
create table (errno: 150)
这个错误是有由于主表和引用表的外键关联字段定义不一致引发的。
检查两个表的关联字段是否类型编码完全一致。
另外还有一种可能就是关联字段在引用表中 ......