File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Save a table with another name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Save a table with another name?" Watch "Save a table with another name?" New topic
Author

Save a table with another name?

Franco Lucci
Greenhorn

Joined: May 07, 2005
Posts: 6
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Franco Lucci
Greenhorn

Joined: May 07, 2005
Posts: 6
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

Joined: May 07, 2005
Posts: 6
Thanks ... I resolved it with
"SELECT * INTO Customers_2005 FROM Customers"

thank you very much for your interest.

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

Franco,
Thanks for posting the final query.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Save a table with another name?