Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

SQL -> Check Column Exists In Table, If Not, Add

DZone's Guide to

SQL -> Check Column Exists In Table, If Not, Add

· Database Zone ·
Free Resource

MariaDB TX, proven in production and driven by the community, is a complete database solution for any and every enterprise — a modern database for modern applications.


IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = ‘TEST’ AND COLUMN_NAME = ‘TEST_DATE’)
BEGIN
   ALTER TABLE TEST ADD TEST_DATE DATETIME
END


MariaDB AX is an open source database for modern analytics: distributed, columnar and easy to use.

Topics:
database ,sql

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}