为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。 【DM版本】:md8 【操作系统】: 【CPU】: 【问题描述】*:增加数据库查询不到自增列的值,返回无效表名
--建表定义为IDENTITY 就用IDENT_CURRENT查 CREATE TABLE T1("id" INT IDENTITY(1, 1) NOT NULL,"name" CHAR(10)) ; insert into t1 values('test1'); insert into t1 values('test2'); commit; select IDENT_CURRENT('SYSDBA.T1'); --建表定义为AUTO_INCREMENT 用select LAST_INSERT_ID();查 create table T2(id int primary key not null AUTO_INCREMENT , name varchar(20) ); insert into t2 values(1,'test1'); insert into t2(name) values('test2');----用AUTO_INCREMENT在插入的时候必须指定列名 insert into t2 values('test3');--报错 -6111 字符串转换出错 commit; select LAST_INSERT_ID(); -- IDENTITY 不支持用 LAST_INSERT_ID -- LAST_INSERT_ID只能是AUTO_INCREMENT的
--建表定义为IDENTITY 就用IDENT_CURRENT查
CREATE TABLE T1("id" INT IDENTITY(1, 1) NOT NULL,"name" CHAR(10)) ;
insert into t1 values('test1');
insert into t1 values('test2');
commit;
select IDENT_CURRENT('SYSDBA.T1');
--建表定义为AUTO_INCREMENT 用select LAST_INSERT_ID();查
create table T2(id int primary key not null AUTO_INCREMENT , name varchar(20) );
insert into t2 values(1,'test1');
insert into t2(name) values('test2');----用AUTO_INCREMENT在插入的时候必须指定列名
insert into t2 values('test3');--报错 -6111 字符串转换出错
commit;
select LAST_INSERT_ID();
-- IDENTITY 不支持用 LAST_INSERT_ID
-- LAST_INSERT_ID只能是AUTO_INCREMENT的