Ошибка 105 sql

Allright so I know this question have been asked multiple times on Stackoverflow and anywhere on the internet. Yet I still can’t seem to figure my problem out…

First I’m creating this table:

create table player
    (   id_player       char(32)    not null,
        joindate        date        not null,
        name            char(32)    not null,
    primary key (id_player)
    );

Then after that when I try to make a second table, that references the first in a foreign key:

create table player_faction
    (   id_player       char(32),
        joindate        date        not null,
        rank            char(20)    not null,
        power           integer,
    foreign key (id_player) references player
        on update cascade
        on delete cascade
    );

It gives me a error 105 which stands for not able to reference to the first table for some reason.
I understand that but I just can’t figure out why?
Is there someone who sees what I’m doing wrong, I’ve been hurting my head on this for the past hour or so…

It is probably a really small, stupid mistake, thanks for helping!

Problem was solved, if you want my solution, look below, it is really stupid!

I wanted to make a database exactly as below:

enter image description here

So I wanted to define the primary and foreign keys for each table.
Based on this answer, I saw that:

  • «city» table has 1 PK (ID) and 1 FK (countrycode)

  • «countrylanguage» table has 2 PK (Language and countrycode) and 1 FK
    (countrycode)

  • «country» table has 1 PK (Code)

So I tried to make some magic on a «pre-heated» code:

CREATE TABLE `City` (
  `ID` int(11) NOT NULL,
  `Name` varchar(35) NOT NULL ,
  `CountryCode` varchar(3) NOT NULL DEFAULT '',
  `District` varchar(20) NOT NULL ,
  `Population` int(11) NOT NULL ,
  PRIMARY KEY(`ID`) ,
  FOREIGN KEY(`CountryCode`) REFERENCES `Country`(`Code`)
) ;

CREATE TABLE `CountryLanguage` (
  `CountryCode` varchar(3) NOT NULL DEFAULT '',
  `Language` varchar(30) NOT NULL ,
  `IsOfficial` varchar(30) NOT NULL ,
  `Percentage` float(4,1) NOT NULL ,
  PRIMARY KEY(`Language`),
  FOREIGN KEY(`CountryCode`) REFERENCES `Country`(`Code`)
  ) ;

CREATE TABLE `Country` (
  `Code` varchar(3) NOT NULL DEFAULT '',
  `Name` varchar(52) NOT NULL DEFAULT '',
  `Continent` varchar(63),
  `Region` varchar(26) NOT NULL DEFAULT '',
  `SurfaceArea` float(10,2) NOT NULL DEFAULT '0.00',
  `IndepYear` smallint(6) DEFAULT NULL,
  `Population` int(11) NOT NULL DEFAULT '0',
  `LifeExpectancy` float(3,1) DEFAULT NULL,
  `GNP` float(10,2) DEFAULT NULL,
  `GNPOld` float(10,2) DEFAULT NULL,
  `LocalName` varchar(45) NOT NULL DEFAULT '',
  `GovernmentForm` varchar(45) NOT NULL DEFAULT '',
  `HeadOfState` varchar(60) DEFAULT NULL,
  `Capital` int(11) DEFAULT NULL,
  `Code2` varchar(2) NOT NULL DEFAULT '',
  PRIMARY KEY(`Code`)
) ;

but my good ol’ mysql command line client has the same ERROR 1005 thing twice, and says that it can’t create tables ‘test.city’ and ‘test.countrylanguage’
with the errno:150 thingy as an explanation.

So I searched a bit around here and I found some answers regarding to table elements not having the same type/parameter (f.e. INT(2) to INT(2) NOT NULL). As fas as I could see, Nothing like this happens here.

What is my coffee-drained brain missing here?

Thank you for your time in advance.

The following error “Unclosed quotation mark after the character string…” occurs when you miss a quotation mark.

When the single quote is used once, and to close statement SQL Server is expecting for another one single quote. In some reason, a user can forget to do it. For example:

BACKUP DATABASE Adventureworks TO DISK = 'diff.bak

In this case, SQL Server will send the following error message:

Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string 'diff.bak'.  

Also, assume that the statement has been copied from MS Word document or website to SSMS and the “Unclosed quotation mark after the character string…” error appears. This happened because a single quote in MS Word or website ( ‘ ) is different from the single quote in SSMS ( ‘ ).

To fix this error just put another one single quote in the beginning or in the end of the statement where it needed:

BACKUP DATABASE Adventureworks TO DISK = 'diff.bak'

Msg 105, Level 15, State 1, Line n
Unclosed quotation mark before the character string ‘%.*ls’

The error msg indicate not correctly formatted
string. In SQL Server it must be enclosed with single quotation mark (‘
‘). 

SQL Server uses the single quote to delimit
strings.  If the data itself contains a single quote you must
pass in two single quotes in order for sql server to process the string
correctly.

SELECT 'Hello

Output:

Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ‘Hello
‘.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘Hello
‘.

SELECT 'Hello'' World'''

Output:

Hello’ World’

Tech Support 24/7

Ask a Tech Specialist Online

Connect with the Expert via email, text or phone. Include photos, documents, and more. Get step-by-step instructions from verified Tech Support Specialists.

Ask a Tech Specialist Online

On this page, you will find more information about the most common causes and most relevant solutions for the SQL error ‘-105’. Do you need help straight away? Visit our support page.

Error information

What causes the -105 error?

The ISO/IEC documentation indicates that error code ‘-105’ is caused by the following problem: «Field validation failed in UPDATE».

Do you think there is another cause for this error? Let others know in the comments.

Tech Support 24/7

Ask a Tech Specialist Online

Connect with the Expert via email, text or phone. Include photos, documents, and more. Get step-by-step instructions from verified Tech Support Specialists.

Ask a Tech Specialist Online

Need more help?

Do you need more help?

Tech experts are ready to answer your questions.

Ask a question

Понравилась статья? Поделить с друзьями:
  • Ошибка 105 pokerstars
  • Ошибка 105 pdf
  • Ошибка 105 dayz
  • Ошибка 10495 genshin impact
  • Ошибка 1040 что это