SA-MP Forums

Go Back   SA-MP Forums > Other > Everything and Nothing

Reply
 
Thread Tools Display Modes
Old 09/01/2019, 03:48 PM   #1
SymonClash
Little Clucker
 
SymonClash's Avatar
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Problem with importing tables

Hello, ok so, i have a problem while importing some tables to my database.

I have this error:

Quote:
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
While importing this tables:

PHP Code:
// 
What's wrong with them?

Last edited by SymonClash; 09/01/2019 at 06:08 PM.
SymonClash is offline   Reply With Quote
Old 09/01/2019, 05:04 PM   #2
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 342
Reputation: 57
Default Re: Problem with importing tables

Do it like this
Code:
CREATE TABLE IF NOT EXISTS thebla
(
  `blabla` ... AUTO_INCREMENT,
  ...
  PRIMARY KEY (`blabla`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
instead of altering after it.

https://dev.mysql.com/doc/refman/8.0...increment.html
__________________
Need Help? Use Search, WIKI, and FAQ

Last edited by RoboN1X; 09/01/2019 at 05:37 PM.
RoboN1X is offline   Reply With Quote
Old 09/01/2019, 05:29 PM   #3
SymonClash
Little Clucker
 
SymonClash's Avatar
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: Problem with importing tables

Made in this way:

PHP Code:
CREATE TABLE IF NOT EXISTS `bans
(
  `
BanIDint(20NOT NULL AUTO_INCREMENT,
  `
Usernamevarchar(24NOT NULL,
  `
BannedByvarchar(24NOT NULL,
  `
BanReasonvarchar(220NOT NULL,
  `
IpAddressvarchar(30NOT NULL,
  `
Datevarchar(50NOT NULL
ENGINE=InnoDB DEFAULT CHARSET=latin1;

PRIMARY KEY (`BanID`); 
But still same problem.
SymonClash is offline   Reply With Quote
Old 09/01/2019, 05:36 PM   #4
Hazon
Little Clucker
 
Join Date: May 2018
Posts: 37
Reputation: 0
Default Re: Problem with importing tables

What about this.

PHP Code:
CREATE TABLE IF NOT EXISTS `bans` (\
  `
BanIDint(20NOT NULL AUTO_INCREMENT, \
  `
Usernamevarchar(24NOT NULL,\
  `
BannedByvarchar(24NOT NULL,\
  `
BanReasonvarchar(220NOT NULL,\
  `
IpAddressvarchar(30NOT NULL,\
  `
Datevarchar(50NOT NULL,\
  
PRIMARY KEY (`BanID`)\
ENGINE=InnoDB DEFAULT CHARSET=latin1;", "", ""); 
Hazon is offline   Reply With Quote
Old 09/01/2019, 06:08 PM   #5
SymonClash
Little Clucker
 
SymonClash's Avatar
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: Problem with importing tables

Ok fixed, now i have a problem with "players" table.

PHP Code:
CREATE TABLE IF NOT EXISTS `players
(
  `
idint(11NOT NULL AUTO_INCREMENT,
  `
usernamevarchar(24NOT NULL,
  `
passwordchar(64NOT NULL,
  `
saltchar(16NOT NULL,
  `
RegisterIPvarchar(24NOT NULL,
  `
RegisterDatevarchar(50NOT NULL,
  `
LastLoginvarchar(36NOT NULL,
  `
Killsmediumint(8NOT NULL DEFAULT '0',
  `
Deathsmediumint(8NOT NULL DEFAULT '0',
  `
Scoreint(10NOT NULL DEFAULT '0',
  `
Moneyint(15NOT NULL DEFAULT '0',
  `
AccountLevelint(1NOT NULL DEFAULT '0',
  `
WantedLevelint(1NOT NULL DEFAULT '0',
  `
PlayerGenderint(1NOT NULL,
  `
PlayingHoursint(12NOT NULL DEFAULT '0',
  `
PlayingMinutesint(12NOT NULL DEFAULT '0',
  `
FirstSpawnint(1NOT NULL,
  `
Jobint(1NOT NULL DEFAULT '0',
  `
Bankint(20NOT NULL DEFAULT '0',
  `
NoPmint(1NOT NULL DEFAULT '0',
  `
VehicleLicenseint(1NOT NULL DEFAULT '0',
  `
MotorbikeLicenseint(1NOT NULL DEFAULT '0',
  `
PlaneLicenseint(1NOT NULL DEFAULT '0',
  `
HelicopterLicenseint(1NOT NULL DEFAULT '0',
  `
BankDepositedint(30NOT NULL DEFAULT '0',
  `
BankWithdrawalint(30NOT NULL DEFAULT '0',
  `
Jailedint(1NOT NULL DEFAULT '0',
  `
Warnsint(1NOT NULL DEFAULT '0',
  `
MarijuanaSeedsint(2NOT NULL DEFAULT '0',
  `
CocaineSeedsint(2NOT NULL DEFAULT '0',
  `
HeroinSeedsint(2NOT NULL DEFAULT '0',
  `
MarijuanaGramsint(30NOT NULL DEFAULT '0',
  `
CocaineGramsint(30NOT NULL DEFAULT '0',
  `
HeroinGramsint(30NOT NULL DEFAULT '0',
  `
MarijuanaEarningsint(30NOT NULL DEFAULT '0',
  `
CocaineEarningsint(30NOT NULL DEFAULT '0',
  `
HeroinEarningsint(30NOT NULL DEFAULT '0',
  `
Deliveriesint(5NOT NULL DEFAULT '0',
  `
EarnedFromDeliveriesint(30NOT NULL DEFAULT '0',
  `
Cuffedint(1NOT NULL DEFAULT '0',
  `
FightStyleint(2NOT NULL DEFAULT '0',
  `
LicensePointsint(2NOT NULL DEFAULT '0',
  `
Skinint(3NOT NULL DEFAULT '0',
  `
Lightersint(1NOT NULL DEFAULT '0',
  `
TotalDeliveredPizzasint(10NOT NULL DEFAULT '0',
  `
TotalTipsEarningsint(10NOT NULL DEFAULT '0',
  `
TotalPizzaEarningsint(10NOT NULL DEFAULT '0',
  `
Helperint(1NOT NULL DEFAULT '0',
  `
Gpsint(1NOT NULL DEFAULT '0',
  `
Ageint(1NOT NULL DEFAULT '0',
  
  `
HasPhoneint(1NOT NULL DEFAULT '0',
  `
PhoneNumberint(20NOT NULL DEFAULT '0',
  `
PhoneStatusint(1NOT NULL DEFAULT '0',
  `
PhoneBoughtDatevarchar(50NOT NULL DEFAULT '0',
  `
PhoneBatteryint(3NOT NULL DEFAULT '0',
  `
PhoneRechargingint(1NOT NULL DEFAULT '0',
  `
TimesChargedint(5NOT NULL DEFAULT '0',
  `
PhoneCreditint(3NOT NULL DEFAULT '0',

  `
pHealthfloat NOT NULL DEFAULT '97',
  `
pArmourfloat NOT NULL,
  
  `
pAccentint(3NOT NULL DEFAULT '0',
  
  `
JoinMsgint(1NOT NULL DEFAULT '1',
  `
LeaveMsgint(1NOT NULL DEFAULT '1',
  `
DistanceTextint(1NOT NULL DEFAULT '1',
  `
MoneyInfoint(1NOT NULL DEFAULT '1',
  `
PhoneBarSettingsint(1NOT NULL DEFAULT '1',
  `
Clockint(1NOT NULL DEFAULT '1',
  `
Locationint(1NOT NULL DEFAULT '1',
  `
RandomMessagesint(1NOT NULL DEFAULT '1',
  
  `
pCurrentTotalFishCaughtint(2NOT NULL DEFAULT '0',  
  `
pCurrentTotalFishLibsint(10NOT NULL DEFAULT '0',
  `
FishingRodint(1NOT NULL DEFAULT '0',  
  `
TotalFishesCaughtint(10NOT NULL DEFAULT '0',
  `
TotalEarnedFromSellingFishint(20NOT NULL DEFAULT '0',  
  `
TotalLbsFishSoldint(20NOT NULL DEFAULT '0',
  
  `
pChatStyleint(1NOT NULL DEFAULT '0'
  
ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `players`
  
ADD PRIMARY KEY (`id`),
  
ADD UNIQUE KEY `username` (`username`); 
Same error.
SymonClash is offline   Reply With Quote
Old 09/01/2019, 06:20 PM   #6
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 342
Reputation: 57
Default Re: Problem with importing tables

Quote:
Originally Posted by SymonClash View Post
Ok fixed, now i have a problem with "players" table.

PHP Code:
CREATE TABLE IF NOT EXISTS `players
(
  `
idint(11NOT NULL AUTO_INCREMENT,
  `
usernamevarchar(24NOT NULL,
  `
passwordchar(64NOT NULL,
  `
saltchar(16NOT NULL,
  `
RegisterIPvarchar(24NOT NULL,
  `
RegisterDatevarchar(50NOT NULL,
  `
LastLoginvarchar(36NOT NULL,
  `
Killsmediumint(8NOT NULL DEFAULT '0',
  `
Deathsmediumint(8NOT NULL DEFAULT '0',
  `
Scoreint(10NOT NULL DEFAULT '0',
  `
Moneyint(15NOT NULL DEFAULT '0',
  `
AccountLevelint(1NOT NULL DEFAULT '0',
  `
WantedLevelint(1NOT NULL DEFAULT '0',
  `
PlayerGenderint(1NOT NULL,
  `
PlayingHoursint(12NOT NULL DEFAULT '0',
  `
PlayingMinutesint(12NOT NULL DEFAULT '0',
  `
FirstSpawnint(1NOT NULL,
  `
Jobint(1NOT NULL DEFAULT '0',
  `
Bankint(20NOT NULL DEFAULT '0',
  `
NoPmint(1NOT NULL DEFAULT '0',
  `
VehicleLicenseint(1NOT NULL DEFAULT '0',
  `
MotorbikeLicenseint(1NOT NULL DEFAULT '0',
  `
PlaneLicenseint(1NOT NULL DEFAULT '0',
  `
HelicopterLicenseint(1NOT NULL DEFAULT '0',
  `
BankDepositedint(30NOT NULL DEFAULT '0',
  `
BankWithdrawalint(30NOT NULL DEFAULT '0',
  `
Jailedint(1NOT NULL DEFAULT '0',
  `
Warnsint(1NOT NULL DEFAULT '0',
  `
MarijuanaSeedsint(2NOT NULL DEFAULT '0',
  `
CocaineSeedsint(2NOT NULL DEFAULT '0',
  `
HeroinSeedsint(2NOT NULL DEFAULT '0',
  `
MarijuanaGramsint(30NOT NULL DEFAULT '0',
  `
CocaineGramsint(30NOT NULL DEFAULT '0',
  `
HeroinGramsint(30NOT NULL DEFAULT '0',
  `
MarijuanaEarningsint(30NOT NULL DEFAULT '0',
  `
CocaineEarningsint(30NOT NULL DEFAULT '0',
  `
HeroinEarningsint(30NOT NULL DEFAULT '0',
  `
Deliveriesint(5NOT NULL DEFAULT '0',
  `
EarnedFromDeliveriesint(30NOT NULL DEFAULT '0',
  `
Cuffedint(1NOT NULL DEFAULT '0',
  `
FightStyleint(2NOT NULL DEFAULT '0',
  `
LicensePointsint(2NOT NULL DEFAULT '0',
  `
Skinint(3NOT NULL DEFAULT '0',
  `
Lightersint(1NOT NULL DEFAULT '0',
  `
TotalDeliveredPizzasint(10NOT NULL DEFAULT '0',
  `
TotalTipsEarningsint(10NOT NULL DEFAULT '0',
  `
TotalPizzaEarningsint(10NOT NULL DEFAULT '0',
  `
Helperint(1NOT NULL DEFAULT '0',
  `
Gpsint(1NOT NULL DEFAULT '0',
  `
Ageint(1NOT NULL DEFAULT '0',
  
  `
HasPhoneint(1NOT NULL DEFAULT '0',
  `
PhoneNumberint(20NOT NULL DEFAULT '0',
  `
PhoneStatusint(1NOT NULL DEFAULT '0',
  `
PhoneBoughtDatevarchar(50NOT NULL DEFAULT '0',
  `
PhoneBatteryint(3NOT NULL DEFAULT '0',
  `
PhoneRechargingint(1NOT NULL DEFAULT '0',
  `
TimesChargedint(5NOT NULL DEFAULT '0',
  `
PhoneCreditint(3NOT NULL DEFAULT '0',

  `
pHealthfloat NOT NULL DEFAULT '97',
  `
pArmourfloat NOT NULL,
  
  `
pAccentint(3NOT NULL DEFAULT '0',
  
  `
JoinMsgint(1NOT NULL DEFAULT '1',
  `
LeaveMsgint(1NOT NULL DEFAULT '1',
  `
DistanceTextint(1NOT NULL DEFAULT '1',
  `
MoneyInfoint(1NOT NULL DEFAULT '1',
  `
PhoneBarSettingsint(1NOT NULL DEFAULT '1',
  `
Clockint(1NOT NULL DEFAULT '1',
  `
Locationint(1NOT NULL DEFAULT '1',
  `
RandomMessagesint(1NOT NULL DEFAULT '1',
  
  `
pCurrentTotalFishCaughtint(2NOT NULL DEFAULT '0',  
  `
pCurrentTotalFishLibsint(10NOT NULL DEFAULT '0',
  `
FishingRodint(1NOT NULL DEFAULT '0',  
  `
TotalFishesCaughtint(10NOT NULL DEFAULT '0',
  `
TotalEarnedFromSellingFishint(20NOT NULL DEFAULT '0',  
  `
TotalLbsFishSoldint(20NOT NULL DEFAULT '0',
  
  `
pChatStyleint(1NOT NULL DEFAULT '0'
  
ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `players`
  
ADD PRIMARY KEY (`id`),
  
ADD UNIQUE KEY `username` (`username`); 
Same error.
Same error, same fix, did you even check the link i posted?

Quote:
Originally Posted by RoboN1X View Post
Do it like this
Code:
CREATE TABLE IF NOT EXISTS thebla
(
  `blabla` ... AUTO_INCREMENT,
  ...
  PRIMARY KEY (`blabla`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
instead of altering after it.

https://dev.mysql.com/doc/refman/8.0...increment.html

It's obviously that you should NOT do it like
Code:
CREATE TABLE IF NOT EXISTS `players`
(
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(24) NOT NULL,
  ...
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `players`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`); 
BUT this:
Code:
CREATE TABLE IF NOT EXISTS `players`
(
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(24) NOT NULL,
  ...
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Don't be lazy to spot the differences.
Do it yourself for every tables with similar issues, don't ask us when you are going to delete it from your own post.

Then this is page for you to learn more (sorry for big font so you know that how important it is):
https://dev.mysql.com/doc/refman/8.0...ate-table.html

If half of them already processed, and you get error in the middle, simply revert it back first before doing again.
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing .pwn in SA:MP Map Editor Mugala SA-MP 0.3.DL 2 05/02/2018 09:02 AM
MySQL Importing Problem??PLS HELP PrednizoN Scripting Help 11 27/04/2016 05:02 PM
Plugins problem when importing files into FTP. REVO-RP Server Support 9 04/06/2015 01:12 PM
Problem importing mapping into SAMP map editor? jremi General 9 01/11/2014 04:11 PM
problem with importing image in this forum Sfinx_17 Everything and Nothing 1 02/08/2009 08:47 PM


All times are GMT. The time now is 10:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.