MySQL Forums
Forum List  »  Newbie

problems with my first base
Posted by: Oleksii Movchan
Date: August 05, 2017 09:42PM

hi guys.

i'm having problems with my first base. could someone please help me?
(shift is almost dead on my laptot so sorry in advance for small letters in code)

i'm trying to execute next code

========================
use newbase;

drop table regions;
create table regions (
id int AUTO_INCREMENT,
name varchar(255) not null unique,
active boolean not null default false,
primary key (id)
);

drop table cities;
create table cities(
id int AUTO_INCREMENT,
name varchar(255) not null unique,
regions_id int not null,
active boolean not null default false,
primary key (id),
foreign key (regions_id) references regions(id)
);
========================
problem 1 - error 1217 (23000) 'cannot delete or update a parent row; a foreign key constraint fails'

problem 2 - error 1050 (42s01) 'table regions already exists'
but i dropped it before, why7

problem 3 - autoincremeting works quite bad. i want it to create id like 1,2,3,4... but sometimes after inserting something in my table it looks like 2,3,5,7...

thanks in advance for your help with these questions.

Options: ReplyQuote


Subject
Written By
Posted
problems with my first base
August 05, 2017 09:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.