Created
February 13, 2020 14:09
-
-
Save churchthecat/ebe23308d6af3f7eeaf6ec318cd06582 to your computer and use it in GitHub Desktop.
ERROR 1005 (HY000)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
får följande fel: | |
MariaDB [skolan]> source ddl_all.sql | |
Query OK, 0 rows affected (0.00 sec) | |
Query OK, 0 rows affected (0.02 sec) | |
Query OK, 0 rows affected, 1 warning (0.00 sec) | |
Query OK, 0 rows affected, 1 warning (0.00 sec) | |
Query OK, 0 rows affected, 1 warning (0.00 sec) | |
Query OK, 0 rows affected, 1 warning (0.00 sec) | |
Query OK, 0 rows affected (0.02 sec) | |
Query OK, 0 rows affected (0.02 sec) | |
ERROR 1005 (HY000) at line 49 in file: 'ddl_all.sql': Can't create table `skolan`.`kurstillfalle` | |
(errno: 150 "Foreign key constraint is incorrectly formed") | |
Efter kommandot show warnings: | |
| Warning | 150 | Create table `skolan`.`kurstillfalle` with foreign key constraint failed. | |
Field type or character set for column 'kursansvarig' does not mach referenced | |
column 'akronym' near 'FOREIGN KEY (kursansvarig) REFERENCES larare(akronym) | |
ur filen: | |
SET NAMES 'utf8'; | |
-- Create scheme for database skolan. | |
-- By anjn19 for course databas. | |
-- 2020-01-20 | |
-- | |
-- | |
-- Create table: larare | |
-- | |
DROP TABLE IF EXISTS larare; | |
DROP TABLE IF EXISTS kurstillfalle; | |
DROP TABLE IF EXISTS kurs; | |
DROP TABLE IF EXISTS t1; | |
DROP TABLE IF EXISTS t2; | |
CREATE TABLE larare | |
( | |
akronym CHAR(3), | |
avdelning CHAR(4), | |
fornamn VARCHAR(20), | |
efternamn VARCHAR(20), | |
kon CHAR(1), | |
lon INT, | |
fodd DATE, | |
PRIMARY KEY (akronym) | |
); | |
-- | |
-- Create table: kurs | |
-- | |
CREATE TABLE kurs | |
( | |
kod CHAR(6) NOT NULL, | |
namn VARCHAR(40), | |
poang FLOAT, | |
niva CHAR(3), | |
PRIMARY KEY (kod) | |
) | |
ENGINE INNODB | |
CHARSET utf8 | |
COLLATE utf8_swedish_ci | |
; | |
CREATE TABLE kurstillfalle | |
( | |
id int NOT NULL AUTO_INCREMENT, | |
kurskod CHAR(6) NOT NULL, | |
kursansvarig CHAR(3) NOT NULL, | |
lasperiod int NOT NULL, | |
PRIMARY KEY (id), | |
FOREIGN KEY (kurskod) REFERENCES kurs(kod), | |
FOREIGN KEY (kursansvarig) REFERENCES larare(akronym) | |
) | |
ENGINE INNODB | |
CHARSET utf8 | |
COLLATE utf8_swedish_ci | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment