Script for Database (How to update structure of table)
Example the table of database is IDENTITY :
CREATE TABLE IDENTITY(
NAMES VARCHAR(50),
AGE INTEGER,
ADDRESS VARCHAR(100));
This is script for update table, how to delete field, add field and update type of field:
ALTER TABLE IDENTITY
DROP COLUMN AGE;
ALTER TABLE IDENTITY
ADD COLUMN CODE INT(5) ;
ALTER TABLE IDENTITY
ALTER COLUMN CODE CHAR(6) ;
CREATE TABLE IDENTITY(
NAMES VARCHAR(50),
AGE INTEGER,
ADDRESS VARCHAR(100));
This is script for update table, how to delete field, add field and update type of field:
- Delete field
ALTER TABLE IDENTITY
DROP COLUMN AGE;
- Add field
ALTER TABLE IDENTITY
ADD COLUMN CODE INT(5) ;
- Update type of field
ALTER TABLE IDENTITY
ALTER COLUMN CODE CHAR(6) ;
No comments