易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql forige key


Love in coding...
    Free and Susan
[引]MySQL INNODB类型表的外键关联设置

Here is a simple example that relates parent and child tables through a single-column foreign key:
CREATE TABLE parent (id INT NOT NULL,
                     PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
                    INDEX par_ind (parent_id),
                    FOREIGN KEY (parent_id) REFERENCES parent(id)
                      ON DELETE CASCADE
) ENGINE=INNODB;
A more complex example in which a product_order table has foreign keys for two other tables.
One foreign key references a two-column index in the product table.
The other references a single-column index in the customer table:
CREATE TABLE product (category INT NOT NULL, id INT NOT NULL,
                      price DECIMAL,
                      PRIMARY KEY(category, id)) ENGINE=INNODB;
CREATE TABLE customer (id INT NOT NULL,
                       PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,
                            product_category INT NOT NULL,
  


相关文档:

Mysql初始化root密码和允许远程访问

Mysql初始化root密码和允许远程访问
mysql默认root用户没有密码,输入mysql –u root 进入mysql
1、初始化root密码
进入mysql数据库
1
mysql>update user set password=PASSWORD(‘123456’) where User='root';
2、允许mysql远程访问,可以使用以下三种方式:
a、改表。
1
mysql -u root – ......

mysql event调用存储过程

mysql event (用来实现定时任务)。mysql

5.1.16
开始拥有的新功能。
下面我写一个简单的示例。
先创建数据库和两个表:
drop database dep;
create database dep;
use dep;
create table aa
(id int AUTO_INCREMENT primary key,
remark varchar(20)
);
create table bb
(id int AUTO_INCREMENT primary k ......

centos 5.Freeradius2.1 mysql 5.0成功安装配置笔记

(1)安装 freeradius-server-2.1.1.tar.gz
[root@localhost freeradius-server-2.1.1]# tar zxvf freeradius-server-2.1.1.tar.gz
[root@localhost freeradius-server-2.1.1]# cd freeradius-server-2.1.1
[root@localhost freeradius-server-2.1.1]# ./configure
[root@localhost freeradius-server-2.1.1]# make
[ ......

Mysql查询时,对于数值型字段加单引号会引起的误解~

假设有表 tb1
ID | name|
----+--------+
1   |2toon|
2   |1*xyz|
语句1:
 select * from  tb1 where ID='2toon' or name ='2toon';
mysql服务器在某模式下,可以执行这条句,就成功返回两条记录,原因在于 ID=‘2toon’ 加了单引号,mysql解释为 ID=2.
语句2
select * fro ......

mysql 时间函数

里是一个使用日期函数的例子。下面的查询选择了所有记录,其date_col的值是在最后30天以内: 
  mysql> SELECT something from table 
  WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30; 
   select   TO_DAYS(NOW());
   select now() ;
  DAYOFWEEK( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号