Skip to main content

Reverse Vertica environment?

  • Apr 23, 2018 9:49 PM UTC
  • 10 replies
  • 34 views

usao
Forum|alt.badge.img
  • Participating Frequently

Is there a tool/utility which can reverse out a Vertica database?
I need to create a TEST environment based on our DEV environment, but I dont think that we have properly recorded all the deployed DDL, Users, Permissions, Schemas etc...
Looking for something which can reverse out the current DEV environment to be used as a template for deploying to a TEST environment.

10 replies

ScottL
Forum|alt.badge.img+1
  • Participating Frequently
  • Apr 25, 2018 3:15 PM UTC

bose4life
  • Participating Frequently
  • Feb 25, 2021 11:10 PM UTC

Please what is the analog of a sql function Reverse on vertica.


Vertica_Curtis
Forum|alt.badge.img+1
  • Participating Frequently
  • Feb 25, 2021 11:35 PM UTC

Probably should be in a separate thread, but I have to ask - what is the use case of such a function?
And no, Vertica doesn't have this function. You'd have to write it in a UDx.


bose4life
  • Participating Frequently
  • Feb 26, 2021 6:23 PM UTC

Is from a sql syntax that need to be executed in vertica to return the range values.
Example of sql expression:
'3_'+IIF(LEN(StoreNo)-PATINDEX('%[0-7]%', StoreNo)-PATINDEX('%[0-7]%, REVERSE(StoreNo))>0, (SUBSTRING(StoreNo, PATINDEX('%[0-7]%', StoreNo),LEN(StoreNo)-PATINDEX('%[0-7]%', StoreNo)-PATINDEX('%[0-7]%', REVERSE(StoreNo)))), NULL)


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • Feb 26, 2021 6:50 PM UTC

@bose4life - Can you give a couple input and output examples?


bose4life
  • Participating Frequently
  • Feb 26, 2021 7:47 PM UTC

Input example : StoreNo S1987256300
Output 3_19872
StoreNo S176540926
Output 3_17654


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • Feb 26, 2021 7:55 PM UTC

Are you sure that's the output expected? If so, why not just do this?

dbadmin=> SELECT store_no, '3' || '_' || SUBSTR(store_no, 2, 5) output FROM store;
  store_no   | output
-------------+---------
 S1987256300 | 3_19872
 S176540926  | 3_17654
(2 rows)


bose4life
  • Participating Frequently
  • Feb 26, 2021 8:00 PM UTC

More Input output example : STU1997756600
Output 3_19977
StoreNo HP186920926
Output 3_18692


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • Feb 26, 2021 8:18 PM UTC
dbadmin=> SELECT store_no, '3' || '_' || LEFT(regexp_replace(store_no, '[^0-9]', ''), 5) FROM store;
   store_no    | ?column?
---------------+----------
 S1987256300   | 3_19872
 S176540926    | 3_17654
 STU1997756600 | 3_19977
 HP186920926   | 3_18692
(4 rows)

bose4life
  • Participating Frequently
  • Feb 26, 2021 10:37 PM UTC

Solution worked efficiently. Thank you I appreciate.