Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Save a table with another name?

 
Franco Lucci
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'd like to do a copy of a table in my DB.mdb with another name
but my problem is to do it with java's code.
Ex: I have the CUSTOMERS table in my personal.mdb and I want create a copy of CUSTOMERS with name CUSTOMERS_2005.
Is it possible?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Franco,
Welcome to JavaRanch!

Yes, you can do this through JDBC. You need to create a new table with the same schema. If you have the schema, you can use it. If not, you can use the metadata to get it. Then you insert all the records into the new table and delete the old table.

If you want more details about any of these steps, post here.
 
Franco Lucci
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but I have to create the classic
CREATE TABLE Person
(
LastName varchar(30),
FirstName varchar,
Address varchar,
Age int(3)
)
and then to put inside all recorsd of my old table ...
Is there a more simple way to do this? for example COPY Person IN Person_2005.
Yes ... if can you explain me better how i can to do take a schema table and create another table?
thank you very much ....
 
Franco Lucci
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ... I resolved it with
"SELECT * INTO Customers_2005 FROM Customers"

thank you very much for your interest.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Franco,
Thanks for posting the final query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic