title: How to get full length of DDL for a table or any object in redshift / postgresql
body: <p>Team, 
  I am working on redshift ( 8.0.2 ). I would like to have DDL command in place for any object type ( table / view...) in redshift. </p>
  
  <p>I have below one. but it is not giving the full text. </p>
  
  <pre><code>select s.userid,u.usename,s.starttime, s.type, rtrim(s.text) from svl_statementtext s, pg_user u
   where u.usesysid = s.userid
   and s.type = 'DDL' 
   and s.text like '%table11%' 
   order by s.starttime asc;
  
   userid |                                                             usename                                                              |         starttime          | type |                                                                                                   text
  --------+----------------------------------------------------------------------------------------------------------------------------------+----------------------------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      143 | user11                                                                                                                           | 2014-04-16 23:42:06.227296 | DDL  | CREATE TABLE table11 ( log_time date, user_name text, database_name text, process_id integer, connection_from text, session_id text, session_line_num bigint, command_tag text, session_start_time
      143 | user11                                                                                                                           | 2014-04-16 23:42:06.234987 | DDL  | CREATE TABLE table11 ( log_time date, user_name text, database_name text, process_id integer, connection_from text, session_id text, session_line_num bigint, command_tag text, session_start_time
  (2 rows)
  </code></pre>
  
  <p>in Oracle we have DDL_METADATA.GET_DDL pkg. it will give the full text. I would like to have the same. I tried with STL_DDLTEXT. text is much trimmed. </p>
  
  <pre><code>select xid, starttime, sequence, substring(text,1,40) as text
  from stl_ddltext where  userid = 100 and text like '%table11%'  order by xid desc, sequence;
    xid   |         starttime          | sequence |                   text
  --------+----------------------------+----------+------------------------------------------
   135475 | 2014-04-16 23:42:06.234987 |        0 | CREATE TABLE table11 ( log_time dat
   135475 | 2014-04-16 23:42:06.227296 |        0 | CREATE TABLE table11 ( log_time dat
  (2 rows)
  </code></pre>
  
  <p>I have few more doubts on the first query output. the column lenght of "usename" is too high. how to trim that. If i query pg_user, it is trimmed internally. IN oracle we can have for e.g. </p>
  
  <pre><code>" col &lt;col_name&gt; for a80  " 
  </code></pre>
  
  <p>second doubt: i am getting 2 rows. actually i created only one table. Any reason for 2 rows in the output ?</p>
  
  <p>for e.g. in physical postgre db, if we want to generate any ddl for one function, 
  we can use below. </p>
  
  <p>in the below, function name is "add" </p>
  
  <pre><code>SELECT pg_catalog.pg_get_functiondef('add'::regproc);
  </code></pre>
  
  <p>like this, do we have any pkg in Redshift for table/views ?</p>
  
  <p>Thanks </p>