Constants in SQL: Constants are numeric characters or values used in a SQL statement.
SELECT NAME FROM EMPLOYEES WHERE EMPL_N > 1020
Here, 1020 is a constant.
Types of constants in SQL:
Numeric constants: Numeric constants are integer and decimal numeric values.
where, E is: times ten to the power of
String constants: String constants are constants for character data.
For a quote, two single quotes are used.
Symbolic constants: Symbolic constants are used to return data value which are managed by the database management system.
For Example: CURRENT_DATE is used to return current date.
Date and Time constants: Date and Time constants are constants for date and time.
For SQL Server, some date constants are:
- March 4, 2013
- Mar 4 2013
- 2013 MAR 4
For SQL Server, some time constants are:
- 5:45:40 AM
- 5:45:40 am
- 5 am