Is there any way to find table creation date in redshift?

前端 未结 3 1308
Happy的楠姐
Happy的楠姐 2021-02-07 23:33

I am having trouble with finding table creation date in Amazon Redshift. I know svv_table_info will give all the info about the table but the creation date.Can anyone help pleas

3条回答
  •  半阙折子戏
    2021-02-08 00:24

    It looks like no way to get the creation timestamp of tables in Redshift. One workaround is using STL_DDLTEXT table which records a history of DDLs including CREATE TABLE.

    Here is an example (test_table is a table name):

    dev=> select starttime, endtime, trim(text) as ddl from stl_ddltext where text ilike '%create%table%test_table%' order by endtime desc limit 1;
             starttime          |          endtime           |                                                               ddl
    ----------------------------+----------------------------+----------------------------------------------------------------------------------------------------------------------------------
     2016-04-25 05:38:11.666338 | 2016-04-25 05:38:11.674947 | CREATE TABLE "test_table" (id int primary key, value varchar(24));
    (1 row)
    

    In the above case, starttime or endtime will be a timestamp of the test_table table creation.

    NOTE:

    • Redshift does not keep STL_DDLTEXT for a long time, so you cannot use this way permanently.
    • You cannot use this way if the table is created through other ways like renaming a table name.

提交回复
热议问题