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

前端 未结 3 1307
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:31

    There is a proper way to get table creation date and time in Redshift, that is not based on query log:

    SELECT
    TRIM(nspname) AS schema_name,
    TRIM(relname) AS table_name,
    relcreationtime AS creation_time
    FROM pg_class_info
    LEFT JOIN pg_namespace ON pg_class_info.relnamespace = pg_namespace.oid
    WHERE reltype != 0
    AND TRIM(nspname) = 'my_schema';
    

    For some reason it does not work for very old tables. The oldest date I could find on a cluster of mine was in November 2018. Maybe the creation date of tables was not recorded in pg_class_info before that date.

提交回复
热议问题