?
Solved

Table Naming Conversion

Posted on 2003-03-26
3
Medium Priority
?
723 Views
Last Modified: 2008-02-26
Hi All,

We need to backup one oracle table every week before it is dropped. I wrote one scripts as:

CREATE TABLE a1backup
AS SELECT * FROM al;

I need to run this as cron every week. My question is how to specify the name of backup table(table name + date)? Like albackup03212003, a1backup31042003, ….

Thanks
Terry
0
Comment
Question by:terrywong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
ypwitkow earned 200 total points
ID: 8216223
You must use dynamic SQL.
First create procedure:

CREATE OR REPLACE PROCEDURE cr_tab AS
sql_text  VARCHAR2(100);
BEGIN
  sql_text := 'CREATE TABLE a1backup'||
              to_char(sysdate,'mmddyyyy')||
              ' AS SELECT * FROM a1';
  execute immediate sql_text;
END;
/

Then call this procedure in your script.
HTH,
Lucy
0
 
LVL 17

Expert Comment

by:walterecook
ID: 10360609
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: ypwitkow {http:#8216223}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

walterecook
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question