I wrote the following SQL in my script, before I wrote I feel it not the best, but just cannot think of it.
SELECT
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TABLE_NAME,'0','#'),
'1','#') ,'2','#') ,'3','#') ,'4','#')
,'5','#') ,'6','#') ,'7','#') ,'8','#') ,'9','#') PATTERN_NAME
FROM USER_TABLES
When taking metro line to home, I reminded the translate function, it's very very simple.
SELECT
TRANSLATE(TABLE_NAME,'0123456789','##########') PATTERN_NAME
FROM USER_TABLES
I want to write the following SQL to find out which tables should have the same structure, and them compare them.
SELECT TABLE_NAME FROM USER_TABLES
WHERE TRANSLATE(TABLE_NAME,'0123456789','##########') IN
(SELECT
TRANSLATE(TABLE_NAME,'0123456789','##########') PATTERN_NAME
FROM USER_TABLES
GROUP BY TRANSLATE(TABLE_NAME,'0123456789','##########')
HAVING COUNT(*) > 1)
Choose right way is very important for us. One of my friend said we could use "REGEXP_REPLACE(TABLE_NAME, '[1-9]', '#' )" in Oracle 10g.
Comments (2)
Now I recognize you compose this English version blog by hand.
I thought you're taking advantage of some tool like Google automatic translation.
Keep up the good work.
Posted by 木匠 Charlie | April 25, 2007 1:54 PM
Actually I wrote it in notepad first, then paste it to the blog.
No translate tools are used except the spell check in Firefox.
Posted by anysql | April 25, 2007 5:50 PM