1

I am developing an application in C# that dynamically creates a table using a user entered query. The syntax I use for this is:

CREATE TABLE <table name> (<user query>)

Is there a way I can add an index to the table that includes all columns without specifying the exact column names. Something like this would be great but this doesn't work:

CREATE INDEX <index name> ON <table name> (*)

Alternatively, is there a way I query for the columns in the database. If I have this information then I can build up the query using the exact column names to add an index after the table is created.

Any help would be greatly appreciated. Thanks in advance.

millie
  • 2,642
  • 10
  • 39
  • 58
  • 3
    Adding indexes to every column doesn't make sense. Database schema aren't meant to be designed through automation. – Corbin Apr 30 '12 at 09:09
  • Why are you indexing all columns? Usually this does not make that much sense. – flash Apr 30 '12 at 09:10
  • 1
    see this answer, it explains why you shouldn't index all columns : http://stackoverflow.com/questions/5447987/why-cant-i-simply-add-an-index-that-includes-all-columns – Zaki Apr 30 '12 at 09:12

1 Answers1

0

You could use

SHOW [FULL] COLUMNS FROM <table name>

to get the columns

Nanne
  • 64,065
  • 16
  • 119
  • 163