0

Does anyone know how to modify a column's datatype in sybaseIQ?

ie i have table: "MY_TABLE" with col STATUS varchar(100) i want to change it to varchar(10)

alter table "MY_TABLE" 
    modify "STATUS" varchar(10)

I have tried, the above, but it doesn't seem to be working.......

    Error: SQL Anywhere Error -1013024: ALTER TABLE MODIFY <column> <datatype> is not supported.
-- (db_alter.cxx 438) SQLState:  QCA24 ErrorCode: 21 

thoughts?

Jackson Ha
  • 662
  • 2
  • 7
  • 13

2 Answers2

2

As the error message states, modifying a columns data type in IQ is not supported. You would need to add a constraint, or add a new column, copy the data, and drop the old column.

You are able to modify the columns nullability, just not the underlying data type.

Hotel
  • 1,361
  • 11
  • 13
0

See below the SAP IQ 16 equivalent of this command, which is NOT ALLOWED once the column has data:

Not allowed: ALTER TABLE MyTableName Modify MyExistingColumnName bigint null;

ALTER TABLE MyTableName ADD    MyExistingColumnName_xxxNEWxxx    bigint null;

UPDATE      MyTableName SET    MyExistingColumnName_xxxNEWxxx =  MyExistingColumnName;

--QA
   select count(1) "QA_RESULT"
   from MyTableName 
   Where MyExistingColumnName_xxxNEWxxx != MyExistingColumnName;

--CRITICAL: QA_RESULT MUST BE 0

--ONLY If QA_RESULT IS 0 
  ALTER TABLE MyTableName DROP   MyExistingColumnName;

  ALTER TABLE MyTableName RENAME MyExistingColumnName_xxxNEWxxx To MyExistingColumnName;

--FINAL QA
    select top 100 * 
    from MyTableName 
    where MyExistingColumnName IS NOT NULL;
----
commit;