mysql - auto_increment with the newly created column -
this question has answer here:
i using mysql, have table called transaction_detail
the create table statement is
create table transaction_detail( tx_code varchar(25), acct varchar(25), ltx varchar(25), crcy varchar(25));
i want add column called line_key auto_increment 1 in this. know way create table similar , add column auto_increment in , insert data table newly created table, looking easier way altering table , adding column incremented value.
this way can insert 1 table another
insert database.tablenamenew select * database.tablenameold;
this way can copy table structure
create table database.tablenamenew database.tablenameold;
this table auto increament
create table transaction_detail( `line_key` int(11) not null auto_increment, `tx_code` varchar(25), `acct` varchar(25), `ltx` varchar(25), `crcy` varchar(25) primary key (`line_key`), );
Comments
Post a Comment