Saturday, March 29, 2008

Constant Table

In database development, sometimes we really need to display some constant data and don’t wanna let user change that constant data. But those data are not so many and don’t wanna create table. For this situation, we’ve one alternative way in SQL to create constant table. The trick is not so advanced but it’s really easy and we already know those statements. We just create one simple view using the following statements:

SELECT CustomerTypeID = 1, CustomerType = ‘Ordinary’
UNION ALL
SELECT CustomerTypeID = 2, CustomerType = ‘Executive’
UINON ALL
SELECT CustomerTypeID = 3, CustomerType = ‘Ultimate’

The above statement will give you one constant table for customer type. If you’ve more type, just edit the view and append another types. You can apply this in All SQL Version. :)

No comments: