Re: SQL-Script question
Posted in 1995
I would agree with Dave's solution, but with one enhancement.
Steps 1 - 6 I would keep, assuming that the serial column is initialized
to 800. Then the only step needed would be to:
7) ALTER TABLE tabname MODIFY (serial_column SMALLINT);
This, I believe, would achieve the desired results. I hope this helps!
Tracy W. Nedd
National Weather Service - DBA
vball@skipper.ssmc.noaa.gov
---------------------------------------------------------
}
} Quoting hsc@hslx.jena.thur.de...
} }
} } I'm currently using Informix Online together with ISQL. I can't solve a
} } simply problem:
} } I've a database with 89 records and I want to add a new column with inventory-
} } numbers. The first value should be 800 and the last one 888. The type of the new
} } column could be Smallinteger but not Serial. I want automatically fill out this
} } new column with the values between 800 and 888.
} } Who knows the solution of this simply problem with ISQL?
} }
} Using just ISQL??? Well, OK, here goes...
}
} 1) dbschema -d dbname -t tabname tabname.sql
} 2) UNLOAD TO tabname.unl SELECT 0, * FROM tabname
} 3) DROP TABLE tabname
} 4) (modify tabname.sql and insert a SERIAL field as the first column)
} 5) isql dbname tabname.sql
} 6) LOAD FROM tabname.unl INSERT INTO tabname
} 7) UNLOAD TO tabname.unl SELECT * FROM tabname
} 8) DROP TABLE tabname
} 9) (modify tabname.sql and change the SERIAL field to a SMALLINT field)
} 10) isql dbname tabname.sql
} 11) LOAD FROM tabname.unl INSERT INTO tabname
}
} Obviously this is not glamorous but you did say "with ISQL".
}
} DAS
} --
} Dave Snyder @ Bell Atlantic - Philadelphia, PA
}
} WORK: ddx85qr@boots.bell-atl.com HOME: dave@das13.snide.com
}