sql for creating alerting tables