SQL : how to change the data type of a column
-
Hi ! My app is using SQLite as a database. I'd like to change the datatype of a column of several tables (for example changing from VARCHAR(10) to VARCHAR(50)) without loosing the existing datas. How can I do this in SQL ? I didn't find anything ! Is it possible ? Thanks for your help ! Jerome
-
Hi ! My app is using SQLite as a database. I'd like to change the datatype of a column of several tables (for example changing from VARCHAR(10) to VARCHAR(50)) without loosing the existing datas. How can I do this in SQL ? I didn't find anything ! Is it possible ? Thanks for your help ! Jerome
Just use the ALTER COLUMN syntax. If I had the following table: CREATE TABLE DContact( CONTACTID INT IDENTITY(1,1), CONTACT VARCHAR(50), COMPANY VARCHAR(50), EMAIL VARCHAR(50) ) I could change things like so: ALTER TABLE DContact ALTER COLUMN Email VARCHAR(100) GO This is TSQL that I wrote and tested, but it should be generic enough to work with your database. *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";