Eporting just projection definitions

Moderator: NorbertKrupa

User avatar
becky
Intermediate
Intermediate
Posts: 118
Joined: Sat Apr 28, 2012 11:37 am

Eporting just projection definitions

Post by becky » Wed Sep 18, 2013 12:26 am

Hey,

How do I export just the projection definitions for a table and not the create table statement? I know I can use the export_objects function, but that includes the table create in the output...

SELECT export_objects('', 'table_name');
THANKS - BECKSTER

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Eporting just projection definitions

Post by id10t » Wed Sep 18, 2013 12:51 am

Hi!

Will work on linux only:

Code: Select all

\set tbl '''customer_dimension'''
SELECT export_objects('', :tbl) \g | awk '{ if ($0 ~ /CREATE PROJECTION/) {proj_started=1}; if (proj_started == 1) {print $0} }';

scutter
Master
Master
Posts: 302
Joined: Tue Aug 07, 2012 2:15 am

Re: Eporting just projection definitions

Post by scutter » Wed Sep 18, 2013 1:46 pm

You could also query for the projection names, and then script export_objects() on just the projections.
Sharon Cutter
Vertica Consultant, Zazz Technologies LLC

User avatar
becky
Intermediate
Intermediate
Posts: 118
Joined: Sat Apr 28, 2012 11:37 am

Re: Eporting just projection definitions

Post by becky » Thu Sep 19, 2013 8:15 am

Thanks! Perfect solution provided by the community again! I didn't know that the export_objects function work on projections. I thought it only worked on tables :shock:
THANKS - BECKSTER

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Eporting just projection definitions

Post by id10t » Thu Sep 19, 2013 12:14 pm

HI!

export_objects function work on table, projection, view, sequence and user-defined SQL function.

zxcvmnb
Newbie
Newbie
Posts: 1
Joined: Fri Oct 30, 2015 12:00 pm

Re: Eporting just projection definitions

Post by zxcvmnb » Fri Oct 30, 2015 12:04 pm

Hi, related query, default projections mostly have same name as anchor table.
In that select export_objects('', '<schm_name.tabl_name>', false) will always print export object for the table and not the projections.
How do we get export_objects output for projections with same name as a table ?

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Eporting just projection definitions

Post by JimKnicely » Fri Oct 30, 2015 1:38 pm

Can you post an example where the default projection name generated by Vertica is the same as the anchor table name?
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica Database Administration”