121 lines
2.9 KiB
Plaintext
121 lines
2.9 KiB
Plaintext
CREATE TABLE t1 (
|
|
id INT AUTO_INCREMENT,
|
|
PRIMARY KEY(id)
|
|
) ENGINE=NDBCLUSTER;
|
|
CREATE TABLE t2 (
|
|
id INT AUTO_INCREMENT,
|
|
KEY(id)
|
|
) ENGINE=NDBCLUSTER;
|
|
ERROR HY000: Can't create table 't2'
|
|
SHOW WARNINGS;
|
|
Level Code Message
|
|
Warning 1296 Got error 4335 'Only one autoincrement column allowed per table. Having a table without primary key uses an autoincr' from NDB
|
|
Error 1005 Can't create table 't2'
|
|
SHOW TABLES;
|
|
Tables_in_test
|
|
t1
|
|
CREATE TABLE t3 (
|
|
id INT AUTO_INCREMENT,
|
|
KEY(id)
|
|
) ENGINE=MYISAM;
|
|
ALTER TABLE t3
|
|
ENGINE NDBCLUSTER;
|
|
ERROR HY000: Can't create destination table for copying alter table
|
|
SHOW WARNINGS;
|
|
Level Code Message
|
|
Warning 1296 Got error 4335 'Only one autoincrement column allowed per table. Having a table without primary key uses an autoincr' from NDB
|
|
Error 1005 Can't create destination table for copying alter table
|
|
SHOW CREATE TABLE t3;
|
|
Table Create Table
|
|
t3 CREATE TABLE `t3` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
KEY `id` (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
|
|
ALTER TABLE t3
|
|
ADD PRIMARY KEY (id);
|
|
SHOW CREATE TABLE t3;
|
|
Table Create Table
|
|
t3 CREATE TABLE `t3` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
PRIMARY KEY (`id`),
|
|
KEY `id` (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
|
|
DROP TABLE t1, t3;
|
|
set @@auto_increment_increment=4;
|
|
set @@auto_increment_offset=1;
|
|
set @@ndb_autoincrement_prefetch_sz=2;
|
|
create table t1 (a int unsigned not null primary key auto_increment)
|
|
engine ndb;
|
|
insert into t1 values ();
|
|
insert into t1 values (2);
|
|
insert into t1 values ();
|
|
insert into t1 values ();
|
|
select * from t1 order by a;
|
|
a
|
|
1
|
|
2
|
|
5
|
|
9
|
|
drop table t1;
|
|
set @@auto_increment_increment=2;
|
|
set @@auto_increment_offset=1;
|
|
First look at default SE behaviour on manual insert unaligned with
|
|
offset + step
|
|
create table t1 (a int unsigned not null primary key auto_increment);
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 9
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 1
|
|
insert into t1 values(18);
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 1
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 19
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 21
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 23
|
|
insert into t1 values(22);
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 23
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 25
|
|
insert into t1 values(28);
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 25
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 29
|
|
insert into t1 values();
|
|
show variables like 'LAST_INSERT_ID';
|
|
Variable_name Value
|
|
last_insert_id 31
|
|
select * from t1 order by a;
|
|
a
|
|
1
|
|
18
|
|
19
|
|
21
|
|
22
|
|
23
|
|
25
|
|
28
|
|
29
|
|
31
|
|
drop table t1;
|