English 中文(简体)
将时间STMP 当作密钥及其默认值
原标题:TIMESTAMP as a key and its default value

在服务器中执行 SQL 脚本

ERROR: 错误 1067: 用户的无效默认值_ 创建

CREATE  TABLE IF NOT EXISTS `kwestionariusz_db`.`Companies` (
  `CompanyId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
  `Name` TEXT NOT NULL ,
  `Users_UserId` INT UNSIGNED NOT NULL ,
  `Users_Created` TIMESTAMP NULL DEFAULT NULL ,
  PRIMARY KEY (`CompanyId`, `Created`, `Users_UserId`, `Users_Created`) ,
  INDEX `fk_Companies_Users1` (`Users_UserId` ASC, `Users_Created` ASC) ,
  CONSTRAINT `fk_Companies_Users1`
    FOREIGN KEY (`Users_UserId` , `Users_Created` )
    REFERENCES `kwestionariusz_db`.`Users` (`UserId` , `Created` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB

因此,基本上,我做错了什么?我不想在创建公司时更新用户- 创建用户- 创建后, 这会打破关系。 另外, 公司。 创建后将更新, 并改变公司. mail 等? 我也不想这样做, 显然, 但是让外国钥匙成为无效的也是错误的, 对不对? 那么我该怎么办呢?

最佳回答

Users_Created 列是主密钥的一部分。 主密钥不能包含无效的列 。

问题回答

尝试这样做 :

`Users_Created` TIMESTAMP DEFAULT 0

将《时代科技方案启动指南》全文改为以下参考文件:

< a href=""http://dev.mysql.com/doc/refman/5.5/en/timestamp- retimination.html" rel="nofollow"11.3.4。 自动初始化和更新NAMESTAMP





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签