Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In SQL, I would like to create a table which can contain generic data types. This types can change from every row. The solution I could come up to is:

     tag VARCHAR(64),
     value BLOB,
     type INTEGER,
     PRIMARY KEY(tag)

Here in the 'type' column I put the type of data contained in value.

Is there a better solution?

share|improve this question
What concrete database system? More advanced things like blob store are not part of "core" SQL query language - but they are highly vendor-specific - so we need to know what database this is for – marc_s Jun 15 '13 at 19:08
@marc_s: The DB I am going to use will probably be PostgreSQL, but my question does not intend to be database specific. – Pietro Jun 22 '13 at 22:11

Why BLOB ? Why not string or varbinary(max) or nvarchar Dot Net Nuke in their database inside table UserProfile have generc column

CREATE TABLE [dbo].[UserProfile](
    [ProfileID] [int] IDENTITY(1,1) NOT NULL,
    [UserID] [int] NOT NULL,
    [PropertyDefinitionID] [int] NOT NULL,
    [PropertyValue] [nvarchar](3750) NULL,
    [PropertyText] [nvarchar](max) NULL,
    [Visibility] [int] NOT NULL,
    [LastUpdatedDate] [datetime] NOT NULL,
    [ExtendedVisibility] [varchar](400) NULL ....
share|improve this answer
I put a BLOB in case I have to store, e.g., an integer or an image. Does it have issues with space in case of small data values? – Pietro Jun 15 '13 at 17:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.