Q
Problem solve Get help with specific problems with your technologies, process and projects.

Changing an ID field from numeric to character

What risks, if any, are there in changing smallint to varchar or text? A user wants to begin using alpha characters...

in an ID field which is currently smallint.

There shouldn't be a problem. Because it's an ID field, you're not going to be doing any arithmetic on its values. The only things to watch out for are:

  1. Change all related tables at the same time. As an ID field, it's probably a primary key, so all the foreign keys that reference it should change too.

  2. Change how new values are generated. This may sound obvious, but if it's an IDENTITY or AUTONUMBER field, it'll stop working, and you have to change the queries that insert new rows to the table.

Performance might be slower on extremely large tables, because indexes are generally faster on integers than on strings -- but since it's a smallint, your table cannot be larger than a few thousand rows, which is a long, long way from being extremely large. You probably won't notice the difference in performance.

For More Information

  • What do you think about this answer? E-mail the edtiors at editor@searchDatabase.com with your feedback.
  • The Best SQL Web Links: tips, tutorials, scripts, and more.
  • Have an SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your technical SQL questions -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

This was last published in April 2002

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close