0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Table data

Posted at

SELECT table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'pg_catalog') -- 排除系统模式
AND EXISTS (
SELECT 1
FROM pg_stat_user_tables
WHERE relname = table_name
)
AND EXISTS (
SELECT 1
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = table_name
AND COLUMN_NAME = 'your_date_column'
)
AND EXISTS (
SELECT 1
FROM (SELECT 1 FROM table_name WHERE your_date_column < NOW() - INTERVAL '3 years' LIMIT 1) AS subquery
);

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?