te statements come from your create
>>>> scripts
>>>> or from a show create table statement? I'm suspicious about the
>>index on
>>>> virtual_users(user).
>>>>
>>>>
>>>> - Original Message -
>>>&g
tements come from your create
>>> scripts
>>> or from a show create table statement? I'm suspicious about the
>index on
>>> virtual_users(user).
>>>
>>>
>>> - Original Message -
>>>> From: "David Mehler"
>>
rs(user).
>>
>>
>> - Original Message -
>>> From: "David Mehler"
>>> To: "MySql"
>>> Sent: Tuesday, 25 April, 2017 23:07:19
>>> Subject: Re: Can not add foreign key constraint
>>
>>> Hello,
>>&g
>>>
>>>>>> Here's the output. I hope it helps.
gt; PRIMARY KEY (`user`),
-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE
CASCADE
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1215 (HY000): Cannot add
LT CURRENT_TIMESTAMP ON
>>>> UPDATE CURRENT_TIMESTAMP,
>>>&g
; UPDATE CURRENT_TIMESTAMP,
>> -> PRIMARY KEY (`user`),
>> -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE
>> CASCADE
>> -> ) ENGINE=InnoDB DEFAULT
-> PRIMARY KEY (`user`),
-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1215 (HY000): Cannot add foreign key constraint
root@localhost [mail]&
-> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP,
-> PRIMARY KEY (`user`),
-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE
CASCADE
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1215 (HY000): C
On 4/24/2017 2:10 PM, Peter Brawley wrote:
On 4/24/2017 12:28, David Mehler wrote:
...snip
Adding in a dummy Create Table for the missing referenced
`virtual_domains`, we have ...
drop table if exists lastauth, virtual_users, virtual_domains;
CREATE TABLE virtual_domains (
id int PRIMA
T EXISTS `lastauth` (
>>>> -> `user` varchar(40) NOT NULL,
>>>> -> `remote_ip` varchar(18) NOT NULL,
>>>> -> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
>>>> UPDATE CURRENT_TIMESTA
ser) ON DELETE
CASCADE
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1215 (HY000): Cannot add foreign key constraint
For the table it's referencing here it is:
CREATE TABLE `virtual_users` (
`id` int(11) NOT NULL auto_increment,
`domain_id` int(11) NO
; `remote_ip` varchar(18) NOT NULL,
>>-> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
>>UPDATE CURRENT_TIMESTAMP,
>>-> PRIMARY KEY (`user`),
>>-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE
>> CASCADE
>>
RROR 1215 (HY000): Cannot add foreign key constraint
For the table it's referencing here it is:
CREATE TABLE `virtual_users` (
`id` int(11) NOT NULL auto_increment,
`domain_id` int(11) NOT NULL,
`user` varchar(40) NOT NULL,
`password` varchar(32) NOT NULL,
`quot
` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP,
-> PRIMARY KEY (`user`),
-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1215 (HY000): Cannot add foreign key cons
On 4/24/2017 9:18, David Mehler wrote:
Hello,
I'm trying to add a table to an existing database. I'm wanting it to get
one of it's fields from an already existing table. I've done this
before in this database. This works:
CREATE TABLE `virtual_users` (
`id` int(11) NOT NULL auto_inc
Am 24.04.2017 um 16:18 schrieb David Mehler:
I'm trying to add a table to an existing database. I'm wanting it to get
one of it's fields from an already existing table. I've done this
before in this database. This works:
CREATE TABLE `virtual_users` (
`id` int(11) NOT NULL auto_inc
Hello,
I'm trying to add a table to an existing database. I'm wanting it to get
one of it's fields from an already existing table. I've done this
before in this database. This works:
CREATE TABLE `virtual_users` (
`id` int(11) NOT NULL auto_increment,
`domain_id` int(11) NOT NULL,
`u
> Date: Sun, 17 May 2009 14:25:55 +0800
> From: nathan.vorbei.t...@gmail.com
> To: mysql@lists.mysql.com
> Subject: how to add foreign key in alter command
>
> Hi guys
> Please tell me the command syntax, how to add a colmmen foreign key in
> alter syntax
> thanks
Hi guys
Please tell me the command syntax, how to add a colmmen foreign key in
alter syntax
thanks
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
doing wrong before. Obviously the walk I took did
me the world of good.
--
View this message in context:
http://www.nabble.com/Add-foreign-key-tf2950373.html#a8252094
Sent from the MySQL - General mailing list archive at Nabble.com.
--
MySQL General Mailing List
For list archives:
Just found this added the name:
ALTER TABLE `mytable`
ADD FOREIGN KEY `fk_mytable_id` ( `id` )
REFERENCES `othertable` ( `id` );
I thought I had tried that - obviously not.
--
View this message in context:
http://www.nabble.com/Add-foreign-key-tf2950373.html#a8251427
Sent from the MySQL
Still on the top of foreign keys :)
I have this statement:
ALTER TABLE `mytable`
ADD FOREIGN KEY ( `id` )
REFERENCES `othertable` ( `id` );
Is there a way I can give this key a specific name (eg 'FK_mytable_id') and
specific the type of reference (eg 'ON UPDATE CASCADE
On 5 Jan 2004, at 21:10, Sid Lane wrote:
on mysql 4.0.14-standard (x86 Linux) when I try the following:
alter table child_table
add ( foreign key (column1, column2)
references parent_table
on delete cascade)
;
on an existing innodb table I get:
ERROR 1005: Can't create table './d
on mysql 4.0.14-standard (x86 Linux) when I try the following:
alter table child_table
add ( foreign key (column1, column2)
references parent_table
on delete cascade)
;
on an existing innodb table I get:
ERROR 1005: Can't create table './dbname/#sql-70f5_b92.frm' (errno: 1
25 matches
Mail list logo