473,651 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error 1005 when creating tables on some servers.

24 New Member
i am using mysql 5.1. i have one table named as resv_record. the format is
Expand|Select|Wrap|Line Numbers
  1. create table resv_record ( book enum('h','c','r','f','t') , resv_id int(8) auto_increment not null , user_id varchar(12) not null , primary key( book , resv_id))engine=myisam;
i am creating a new table named flight_book as
Expand|Select|Wrap|Line Numbers
  1. create table flight_booking ( resv_id int(8) not null , jrny_dt date not null , from_place varchar(20) not null, destination varchar(20) not null , class varchar(20) not null , flight_pref1 varchar(50) ,flight_pref2 varchar(50),flight_pref3 varchar(50), primary key (resv_id) , foreign key (resv_id) references resv_record(resv_id));

and i am having an error which says...can't create table(err 150) ...error no 1005.
please help.
May 21 '09 #1
9 2941
prabirchoudhury
162 New Member
hey .. it seems to be alright to me .. this error happening when you do mistake on the foreign key data type mismatch with the original primary key data type. but here looks ok. i did tested on mysql >5 and could create both table and no error . it might have other problem ..

good luck ...
May 22 '09 #2
AmiMitra
24 New Member
actually i created both the tables in one machine and it did not give any error but when trying to do the same in another machine...givin g this error... i simply dont know what to do...
May 22 '09 #3
Atli
5,058 Recognized Expert Expert
Hi.

I'm guessing the problem is that you are creating a foreign key in a non-engine-specific table that is set to reference a field in a table specifically marked as a MyISAM table.
InnoDB tables referencing fields in MyISAM tables should give you an error like that.

If you do not specify the engine (like your second table) the default engine will be used. The engine used by default depends on the server, so servers set up to use InnoDB will give you this error, while those set up to use MyISAM will not.

MyISAM tables do not enforce foreign key relationships, so a MyISAM table created with a broken foreign key should (for now) work fine. (Except for not enforcing the key, obviously)

So, to solve this try to do any of the following:
  • Specifically mark both tables as InnoDB. (Using the engine clause, like in your first table.)
  • Specifically mark both tables as MyISAM and remove the foreign key restraint. (It won't be used anyways, so why bother having it?)
  • Don't specify the engine used for either table and let the server decide what to do.
May 22 '09 #4
AmiMitra
24 New Member
if i specify the first table as innodb or dont specify anything at all...then the first table cannot be created..it gives an error which says ...auto increment should be assigned to only one column and that must be declared as primary key..only myisam lets me create the table as i want it.

i didnot try specifying the 2nd table as myisam...but as u told...that table wont use the foreign key constraint.

so what to do now?
May 22 '09 #5
Atli
5,058 Recognized Expert Expert
Ok.

So apparently, compound primary keys that include an auto_increment field do work in MyISAM, but not in InnoDB.
(See 13.6.14. Restrictions on InnoDB Tables and Bug #15109)

Which gives you two choices.
  1. Define both tables as InnoDB and define `resv_id` in `resv_record` as a Key as well as including it in the Primary Key. (Or simply remove `book` from the Primary Key)
    This will preserve the FK constraint, but it will not give you a independent `resv_id` count per each `book`. (Which is what I assume the whole point of the compound key was?)
  2. Define both tables as MyISAM and lose the FK constraint.
    This, by the way, is what MySQL did silently on your old server.
May 23 '09 #6
AmiMitra
24 New Member
yes u got it right...i want a seperate resv_id count for each book...but what is very surprising to me is that...i have created both of the tables in one machine. and it gave out no error. then i simply saved the queries and then copy pasted in another machine, where it is giving this error. how come that is possible? and obviously i have downloaded mysql from the same site in both the machines.
May 23 '09 #7
Atli
5,058 Recognized Expert Expert
It's most likely because your first server was set up to use MyISAM as the default storage engine, while your second server was set up to use InnoDB.

Your first servers, using MyISAM as a default, would simply drop the FK constraint in your second table, which would then be created without an error.

Your second server, using InnoDB as a default, would try to keep the FK constraint, giving you the 1005 error.

The problem was always there, but the first server just didn't have to check for it.
May 23 '09 #8
AmiMitra
24 New Member
ok, that might be the cause. so if i want to continue with the idea that a seperate resv_id count shud be there for each book , i have to go without the foreign key constraint.
thanx a ton for all your concern. this site is really being helpful to me for my project.
May 23 '09 #9
Atli
5,058 Recognized Expert Expert
Yep, for now at least it seems it has to be either the FK or the independent count.

Just out of interest, why do you want each book to have an independent count?
I can't really think of a good reason why this would be needed.
May 24 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1193
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select database(); +------------+ | database() | +------------+
0
3034
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
3
4142
by: dstewart | last post by:
Situation: One common MySQL database server on SuSE 9.1 with all updates. Uses 'rinetd'. Has entries for the appropriate IP addresses of all servers. NOTE: If the appropirate entries are NOT in rinetd, the error message is: ERROR 2013: Lost connection to MySQL server during query Using the exact same query from prompt on several clients (some are SuSE 9.1, some are older Redhat systems, but none are configured
11
2533
by: frr | last post by:
Hi, After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error: >>> import themes Traceback (most recent call last): File "<interactive input>", line 1, in ? File "themes.py", line 564 font = self.font.makeBlackAndWhite(), additive = self.additive,
0
1481
by: Megan | last post by:
Hi Everybody- I know that this is a really, really long post, but I wanted to try to give you as much background as possible. So here's a quick overview of the issues I'm asking for help with: 1.) I'm trying to create a many to many relationship, and I get the following Error when I try to enforce referential integrity.
3
15782
by: bill_hounslow | last post by:
I'm trying to transfer data from one Sql Server into a table on another, using a simple INSERT query in an Access database with links to tables on both servers (the reasons for this are complicated but it IS the simplest solution, believe me). The 'Select' clause of the query works fine when run alone, but, when I run the INSERT query I get a Runtime Error 3167 Record Deleted. I get the error even when I'm the only person accessing...
4
2693
by: scottrm | last post by:
We have two developers, call them A and B, (on Windows XP) developing a number of asp.net web sites on a shared server (Windows 2003). Everything has been ok but recently for no apparent reason whenever developer A builds a particular project (which builds with no errors) and then tries to access the web site they just built they get the error below. Other projects built by the developer A are ok and also if the other developer, developer...
0
2045
by: Kevin | last post by:
I'm writing a service in VB.NET. Reference the following code: Dim oStreamWriter As StreamWriter .... .... .... oStreamWriter = File.CreateText(TempLogFile) If Err.Number <> 0 Then EventLog.WriteEntry("LogService", "Error Creating Log File: " & _ TempLogFile & vbCrLf & _
1
2728
by: =?Utf-8?B?VmlqYXkgQ2hpa3Rl?= | last post by:
Hi Experts, With Session Affinity and Web Server Farm on ISA Server 2006 accessing 2 backend IIS servers, I’m getting error “Validation of ViewState MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKeyconfiguration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster”. Here is the scenario when I got the error.
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.