Creating a new table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi:
How do I create a table from an sql command?

I pass a select command "select col1,col2 from ......"
and I want to create a new table.
Is any class for this ?

Thanks
 
The SQL syntax for CREATE TABLE is

CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
.... )

So, if we are to create the customer table specified as above, we may type
in

CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date)
 
Thanks John, I was looking for some sort of a class. where we pass parameters .
but otherwise I will use SQL to accomplish this task.
thanks again
 
John,

Is there an SQL command to create a table if the table doesn't already
exist?

Thanks,
Matt
 
You can create your own class, but the SQL Statement would be the basis of
your class (the part that actually creates the table). Create a loop to
collect the Columns and add it to the SQL Statement.
 
Raulavi,

Add this as an answer to your original question next time. My answer would
not have changed, however than I had seen it.

Thanks in advance.

Cor
 
That's a standard SQL command. I use anywhere from MS Access to MS SQL
Server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top