Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL : how to change the data type of a column

SQL : how to change the data type of a column

Scheduled Pinned Locked Moved Database
databasetutorialquestionsqlitehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jerome Conus
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • J Jerome Conus

      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

      A Offline
      A Offline
      afronaut
      wrote on last edited by
      #2

      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";

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups