SQL Reference

Results: 339

ID SQL Resource Description Type
1 ADD Adds a column in an existing table Keyword
2 ADD CONSTRAINT Adds a constraint after a table is already created Keyword
3 ALTER Adds, deletes, or modifies columns in a table, or changes the data type of a column in a table Keyword
4 ALTER COLUMN Changes the data type of a column in a table Keyword
5 ALTER TABLE Adds, deletes, or modifies columns in a table Keyword
6 ALL Returns true if all of the subquery values meet the condition Keyword
7 AND Only includes rows where both conditions is true Keyword
8 ANY Returns true if any of the subquery values meet the condition Keyword
9 AS Renames a column or table with an alias Keyword
10 ASC Sorts the result set in ascending order Keyword
11 BACKUP DATABASE Creates a back up of an existing database Keyword
12 BETWEEN Selects values within a given range Keyword
13 CASE Creates different outputs based on conditions Keyword
14 CHECK A constraint that limits the value that can be placed in a column Keyword
15 COLUMN Changes the data type of a column or deletes a column in a table Keyword
16 CONSTRAINT Adds or deletes a constraint Keyword
17 CREATE Creates a database, index, view, table, or procedure Keyword
18 CREATE DATABASE Creates a new SQL database Keyword
19 CREATE INDEX Creates an index on a table (allows duplicate values) Keyword
20 CREATE OR REPLACE VIEW Updates a view Keyword
21 CREATE TABLE Creates a new table in the database Keyword
22 CREATE PROCEDURE Creates a stored procedure Keyword
23 CREATE UNIQUE INDEX Creates a unique index on a table (no duplicate values) Keyword
24 CREATE VIEW Creates a view based on the result set of a SELECT statement Keyword
25 DATABASE Creates or deletes an SQL database Keyword
26 DEFAULT A constraint that provides a default value for a column Keyword
27 DELETE Deletes rows from a table Keyword
28 DESC Sorts the result set in descending order Keyword
29 DISTINCT Selects only distinct (different) values Keyword
30 DROP Deletes a column, constraint, database, index, table, or view Keyword
31 DROP COLUMN Deletes a column in a table Keyword
32 DROP CONSTRAINT Deletes a UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK constraint Keyword
33 DROP DATABASE Deletes an existing SQL database Keyword
34 DROP DEFAULT Deletes a DEFAULT constraint Keyword
35 DROP INDEX Deletes an index in a table Keyword
36 DROP TABLE Deletes an existing table in the database Keyword
37 DROP VIEW Deletes a view Keyword
38 EXEC Executes a stored procedure Keyword
39 EXISTS Tests for the existence of any record in a subquery Keyword
40 FOREIGN KEY A constraint that is a key used to link two tables together Keyword
41 FROM Specifies which table to select or delete data from Keyword
42 FULL OUTER JOIN Returns all rows when there is a match in either left table or right table Keyword
43 GROUP BY Groups the result set (used with aggregate functions: COUNT, MAX, MIN, SUM, AVG) Keyword
44 HAVING Used instead of WHERE with aggregate functions Keyword
45 IN Allows you to specify multiple values in a WHERE clause Keyword
46 INDEX Creates or deletes an index in a table Keyword
47 INNER JOIN Returns rows that have matching values in both tables Keyword
48 INSERT INTO Inserts new rows in a table Keyword
49 INSERT INTO SELECT Copies data from one table into another table Keyword
50 IS NULL Tests for empty values Keyword
51 IS NOT NULL Tests for non-empty values Keyword
52 JOIN Joins tables Keyword
53 LEFT JOIN Returns all rows from the left table, and the matching rows from the right table Keyword
54 LIKE Searches for a specified pattern in a column Keyword
55 LIMIT Specifies the number of records to return in the result set Keyword
56 NOT Only includes rows where a condition is not true Keyword
57 NOT NULL A constraint that enforces a column to not accept NULL values Keyword
58 OR Includes rows where either condition is true Keyword
59 ORDER BY Sorts the result set in ascending or descending order Keyword
60 OUTER JOIN Returns all rows when there is a match in either left table or right table Keyword
61 PRIMARY KEY A constraint that uniquely identifies each record in a database table Keyword
62 PROCEDURE A stored procedure Keyword
63 RIGHT JOIN Returns all rows from the right table, and the matching rows from the left table Keyword
64 ROWNUM Specifies the number of records to return in the result set Keyword
65 SELECT Selects data from a database Keyword
66 SELECT DISTINCT Selects only distinct (different) values Keyword
67 SELECT INTO Copies data from one table into a new table Keyword
68 SELECT TOP Specifies the number of records to return in the result set Keyword
69 SET Specifies which columns and values that should be updated in a table Keyword
70 TABLE Creates a table, or adds, deletes, or modifies columns in a table, or deletes a table or data inside a table Keyword
71 TOP Specifies the number of records to return in the result set Keyword
72 TRUNCATE TABLE Deletes the data inside a table, but not the table itself Keyword
73 UNION Combines the result set of two or more SELECT statements (only distinct values) Keyword
74 UNION ALL Combines the result set of two or more SELECT statements (allows duplicate values) Keyword
75 UNIQUE A constraint that ensures that all values in a column are unique Keyword
76 UPDATE Updates existing rows in a table Keyword
77 VALUES Specifies the values of an INSERT INTO statement Keyword
78 VIEW Creates, updates, or deletes a view Keyword
79 WHERE Filters a result set to include only records that fulfill a specified condition Keyword
80 ASCII Returns the ASCII value for the specific character String Function
81 CHAR_LENGTH Returns the length of a string (in characters) String Function
82 CHARACTER_LENGTH Returns the length of a string (in characters) String Function
83 CONCAT Adds two or more expressions together String Function
84 CONCAT_WS Adds two or more expressions together with a separator String Function
85 FIELD Returns the index position of a value in a list of values String Function
86 FIND_IN_SET Returns the position of a string within a list of strings String Function
87 FORMAT Formats a number to a format like "#,###,###.##", rounded to a specified number of decimal places String Function
88 INSERT Inserts a string within a string at the specified position and for a certain number of characters String Function
89 INSTR Returns the position of the first occurrence of a string in another string String Function
90 LCASE Converts a string to lower-case String Function
91 LEFT Extracts a number of characters from a string (starting from left) String Function
92 LENGTH Returns the length of a string (in bytes) String Function
93 LOCATE Returns the position of the first occurrence of a substring in a string String Function
94 LOWER Converts a string to lower-case String Function
95 LPAD Left-pads a string with another string, to a certain length String Function
96 LTRIM Removes leading spaces from a string String Function
97 MID Extracts a substring from a string (starting at any position) String Function
98 POSITION Returns the position of the first occurrence of a substring in a string String Function
99 REPEAT Repeats a string as many times as specified String Function
100 REPLACE Replaces all occurrences of a substring within a string, with a new substring String Function
101 REVERSE Reverses a string and returns the result String Function
102 RIGHT Extracts a number of characters from a string (starting from right) String Function
103 RPAD Right-pads a string with another string, to a certain length String Function
104 RTRIM Removes trailing spaces from a string String Function
105 SPACE Returns a string of the specified number of space characters String Function
106 STRCMP Compares two strings String Function
107 SUBSTR Extracts a substring from a string (starting at any position) String Function
108 SUBSTRING Extracts a substring from a string (starting at any position) String Function
109 SUBSTRING_INDEX Returns a substring of a string before a specified number of delimiter occurs String Function
110 TRIM Removes leading and trailing spaces from a string String Function
111 UCASE Converts a string to upper-case String Function
112 UPPER Converts a string to upper-case String Function
113 ABS Returns the absolute value of a number Numeric Function
114 ACOS Returns the arc cosine of a number Numeric Function
115 ASIN Returns the arc sine of a number Numeric Function
116 ATAN Returns the arc tangent of one or two numbers Numeric Function
117 ATAN2 Returns the arc tangent of two numbers Numeric Function
118 AVG Returns the average value of an expression Numeric Function
119 CEIL Returns the smallest integer value that is >= to a number Numeric Function
120 CEILING Returns the smallest integer value that is >= to a number Numeric Function
121 COS Returns the cosine of a number Numeric Function
122 COT Returns the cotangent of a number Numeric Function
123 COUNT Returns the number of records returned by a select query Numeric Function
124 DEGREES Converts a value in radians to degrees Numeric Function
125 DIV Used for integer division Numeric Function
126 EXP Returns e raised to the power of a specified number Numeric Function
127 FLOOR Returns the largest integer value that is <= to a number Numeric Function
128 GREATEST Returns the greatest value of the list of arguments Numeric Function
129 LEAST Returns the smallest value of the list of arguments Numeric Function
130 LN Returns the natural logarithm of a number Numeric Function
131 LOG Returns the natural logarithm of a number, or the logarithm of a number to a specified base Numeric Function
132 LOG10 Returns the natural logarithm of a number to base 10 Numeric Function
133 LOG2 Returns the natural logarithm of a number to base 2 Numeric Function
134 MAX Returns the maximum value in a set of values Numeric Function
135 MIN Returns the minimum value in a set of values Numeric Function
136 MOD Returns the remainder of a number divided by another number Numeric Function
137 PI Returns the value of PI Numeric Function
138 POW Returns the value of a number raised to the power of another number Numeric Function
139 POWER Returns the value of a number raised to the power of another number Numeric Function
140 RADIANS Converts a degree value into radians Numeric Function
141 RAND Returns a random number Numeric Function
142 ROUND Rounds a number to a specified number of decimal places Numeric Function
143 SIGN Returns the sign of a number Numeric Function
144 SIN Returns the sine of a number Numeric Function
145 SQRT Returns the square root of a number Numeric Function
146 SUM Calculates the sum of a set of values Numeric Function
147 TAN Returns the tangent of a number Numeric Function
148 TRUNCATE Truncates a number to the specified number of decimal places Numeric Function
149 ADDDATE Adds a time/date interval to a date and then returns the date Date Function
150 ADDTIME Adds a time interval to a time/datetime and then returns the time/datetime Date Function
151 CURDATE Returns the current date Date Function
152 CURRENT_DATE Returns the current date Date Function
153 CURRENT_TIME Returns the current time Date Function
154 CURRENT_TIMESTAMP Returns the current date and time Date Function
155 CURTIME Returns the current time Date Function
156 DATE Extracts the date part from a datetime expression Date Function
157 DATEDIFF Returns the number of days between two date values Date Function
158 DATE_ADD Adds a time/date interval to a date and then returns the date Date Function
159 DATE_FORMAT Formats a date Date Function
160 DATE_SUB Subtracts a time/date interval from a date and then returns the date Date Function
161 DAY Returns the day of the month for a given date Date Function
162 DAYNAME Returns the weekday name for a given date Date Function
163 DAYOFMONTH Returns the day of the month for a given date Date Function
164 DAYOFWEEK Returns the weekday index for a given date Date Function
165 DAYOFYEAR Returns the day of the year for a given date Date Function
166 EXTRACT Extracts a part from a given date Date Function
167 FROM_DAYS Returns a date from a numeric datevalue Date Function
168 HOUR Returns the hour part for a given date Date Function
169 LAST_DAY Extracts the last day of the month for a given date Date Function
170 LOCALTIME Returns the current date and time Date Function
171 LOCALTIMESTAMP Returns the current date and time Date Function
172 MAKEDATE Creates and returns a date based on a year and a number of days value Date Function
173 MAKETIME Creates and returns a time based on an hour, minute, and second value Date Function
174 MICROSECOND Returns the microsecond part of a time/datetime Date Function
175 MINUTE Returns the minute part of a time/datetime Date Function
176 MONTH Returns the month part for a given date Date Function
177 MONTHNAME Returns the name of the month for a given date Date Function
178 NOW Returns the current date and time Date Function
179 PERIOD_ADD Adds a specified number of months to a period Date Function
180 PERIOD_DIFF Returns the difference between two periods Date Function
181 QUARTER Returns the quarter of the year for a given date value Date Function
182 SECOND Returns the seconds part of a time/datetime Date Function
183 SEC_TO_TIME Returns a time value based on the specified seconds Date Function
184 STR_TO_DATE Returns a date based on a string and a format Date Function
185 SUBDATE Subtracts a time/date interval from a date and then returns the date Date Function
186 SUBTIME Subtracts a time interval from a datetime and then returns the time/datetime Date Function
187 SYSDATE Returns the current date and time Date Function
188 TIME Extracts the time part from a given time/datetime Date Function
189 TIME_FORMAT Formats a time by a specified format Date Function
190 TIME_TO_SEC Converts a time value into seconds Date Function
191 TIMEDIFF Returns the difference between two time/datetime expressions Date Function
192 TIMESTAMP Returns a datetime value based on a date or datetime value Date Function
193 TO_DAYS Returns the number of days between a date and date "0000-00-00" Date Function
194 WEEK Returns the week number for a given date Date Function
195 WEEKDAY Returns the weekday number for a given date Date Function
196 WEEKOFYEAR Returns the week number for a given date Date Function
197 YEAR Returns the year part for a given date Date Function
198 YEARWEEK Returns the year and week number for a given date Date Function
199 BIN Returns a binary representation of a number Advanced Function
200 BINARY Converts a value to a binary string Advanced Function
201 CASE Goes through conditions and return a value when the first condition is met Advanced Function
202 CAST Converts a value (of any type) into a specified datatype Advanced Function
203 COALESCE Returns the first non-null value in a list Advanced Function
204 CONNECTION_ID Returns the unique connection ID for the current connection Advanced Function
205 CONV Converts a number from one numeric base system to another Advanced Function
206 CONVERT Converts a value into the specified datatype or character set Advanced Function
207 CURRENT_USER Returns the user name and host name for the MySQL account that the server used to authenticate the current client Advanced Function
208 DATABASE Returns the name of the current database Advanced Function
209 IF Returns a value if a condition is TRUE, or another value if a condition is FALSE Advanced Function
210 IFNULL Return a specified value if the expression is NULL, otherwise return the expression Advanced Function
211 ISNULL Returns 1 or 0 depending on whether an expression is NULL Advanced Function
212 LAST_INSERT_ID Returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table Advanced Function
213 NULLIF Compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned Advanced Function
214 SESSION_USER Returns the current MySQL user name and host name Advanced Function
215 SYSTEM_USER Returns the current MySQL user name and host name Advanced Function
216 USER Returns the current MySQL user name and host name Advanced Function
217 VERSION Returns the current version of the MySQL database Advanced Function
218 ASCII Returns the ASCII value for the specific character Server String Function
219 CHAR Returns the character based on the ASCII code Server String Function
220 CHARINDEX Returns the position of a substring in a string Server String Function
221 CONCAT Adds two or more strings together Server String Function
222 Concat with + Adds two or more strings together Server String Function
223 CONCAT_WS Adds two or more strings together with a separator Server String Function
224 DATALENGTH Returns the number of bytes used to represent an expression Server String Function
225 DIFFERENCE Compares two SOUNDEX values, and returns an integer value Server String Function
226 FORMAT Formats a value with the specified format Server String Function
227 LEFT Extracts a number of characters from a string (starting from left) Server String Function
228 LEN Returns the length of a string Server String Function
229 LOWER Converts a string to lower-case Server String Function
230 LTRIM Removes leading spaces from a string Server String Function
231 NCHAR Returns the Unicode character based on the number code Server String Function
232 PATINDEX Returns the position of a pattern in a string Server String Function
233 QUOTENAME Returns a Unicode string with delimiters added to make the string a valid SQL Server delimited identifier Server String Function
234 REPLACE Replaces all occurrences of a substring within a string, with a new substring Server String Function
235 REPLICATE Repeats a string a specified number of times Server String Function
236 REVERSE Reverses a string and returns the result Server String Function
237 RIGHT Extracts a number of characters from a string (starting from right) Server String Function
238 RTRIM Removes trailing spaces from a string Server String Function
239 SOUNDEX Returns a four-character code to evaluate the similarity of two strings Server String Function
240 SPACE Returns a string of the specified number of space characters Server String Function
241 STR Returns a number as string Server String Function
242 STUFF Deletes a part of a string and then inserts another part into the string, starting at a specified position Server String Function
243 SUBSTRING Extracts some characters from a string Server String Function
244 TRANSLATE Returns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument. Server String Function
245 TRIM Removes leading and trailing spaces (or other specified characters) from a string Server String Function
246 UNICODE Returns the Unicode value for the first character of the input expression Server String Function
247 UPPER Converts a string to upper-case Server String Function
248 ABS Returns the absolute value of a number Server Math/Numeric Function
249 ACOS Returns the arc cosine of a number Server Math/Numeric Function
250 ASIN Returns the arc sine of a number Server Math/Numeric Function
251 ATAN Returns the arc tangent of a number Server Math/Numeric Function
252 ATN2 Returns the arc tangent of two numbers Server Math/Numeric Function
253 AVG Returns the average value of an expression Server Math/Numeric Function
254 CEILING Returns the smallest integer value that is >= a number Server Math/Numeric Function
255 COUNT Returns the number of records returned by a select query Server Math/Numeric Function
256 COS Returns the cosine of a number Server Math/Numeric Function
257 COT Returns the cotangent of a number Server Math/Numeric Function
258 DEGREES Converts a value in radians to degrees Server Math/Numeric Function
259 EXP Returns e raised to the power of a specified number Server Math/Numeric Function
260 FLOOR Returns the largest integer value that is <= to a number Server Math/Numeric Function
261 LOG Returns the natural logarithm of a number, or the logarithm of a number to a specified base Server Math/Numeric Function
262 LOG10 Returns the natural logarithm of a number to base 10 Server Math/Numeric Function
263 MAX Returns the maximum value in a set of values Server Math/Numeric Function
264 MIN Returns the minimum value in a set of values Server Math/Numeric Function
265 PI Returns the value of PI Server Math/Numeric Function
266 POWER Returns the value of a number raised to the power of another number Server Math/Numeric Function
267 RADIANS Converts a degree value into radians Server Math/Numeric Function
268 RAND Returns a random number Server Math/Numeric Function
269 ROUND Rounds a number to a specified number of decimal places Server Math/Numeric Function
270 SIGN Returns the sign of a number Server Math/Numeric Function
271 SIN Returns the sine of a number Server Math/Numeric Function
272 SQRT Returns the square root of a number Server Math/Numeric Function
273 SQUARE Returns the square of a number Server Math/Numeric Function
274 SUM Calculates the sum of a set of values Server Math/Numeric Function
275 TAN Returns the tangent of a number Server Math/Numeric Function
276 CURRENT_TIMESTAMP Returns the current date and time Server Date Function
277 DATEADD Adds a time/date interval to a date and then returns the date Server Date Function
278 DATEDIFF Returns the difference between two dates Server Date Function
279 DATEFROMPARTS Returns a date from the specified parts (year, month, and day values) Server Date Function
280 DATENAME Returns a specified part of a date (as string) Server Date Function
281 DATEPART Returns a specified part of a date (as integer) Server Date Function
282 DAY Returns the day of the month for a specified date Server Date Function
283 GETDATE Returns the current database system date and time Server Date Function
284 GETUTCDATE Returns the current database system UTC date and time Server Date Function
285 ISDATE Checks an expression and returns 1 if it is a valid date, otherwise 0 Server Date Function
286 MONTH Returns the month part for a specified date (a number from 1 to 12) Server Date Function
287 SYSDATETIME Returns the date and time of the SQL Server Server Date Function
288 YEAR Returns the year part for a specified date Server Date Function
289 CAST Converts a value (of any type) into a specified datatype Server Advanced Function
290 COALESCE Returns the first non-null value in a list Server Advanced Function
291 CONVERT Converts a value (of any type) into a specified datatype Server Advanced Function
292 CURRENT_USER Returns the name of the current user in the SQL Server database Server Advanced Function
293 IIF Returns a value if a condition is TRUE, or another value if a condition is FALSE Server Advanced Function
294 ISNULL Return a specified value if the expression is NULL, otherwise return the expression Server Advanced Function
295 ISNUMERIC Tests whether an expression is numeric Server Advanced Function
296 NULLIF Returns NULL if two expressions are equal Server Advanced Function
297 SESSION_USER Returns the name of the current user in the SQL Server database Server Advanced Function
298 SESSIONPROPERTY Returns the session settings for a specified option Server Advanced Function
299 SYSTEM_USER Returns the login name for the current user Server Advanced Function
300 USER_NAME Returns the database user name based on the specified id Server Advanced Function
301 CHAR(size) A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1 String Data Type
302 VARCHAR(size) A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters - can be from 0 to 65535 String Data Type
303 BINARY(size) Equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default is 1 String Data Type
304 VARBINARY(size) Equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the maximum column length in bytes. String Data Type
305 TINYBLOB For BLOBs (Binary Large OBjects). Max length: 255 bytes String Data Type
306 TINYTEXT Holds a string with a maximum length of 255 characters String Data Type
307 TEXT(size) Holds a string with a maximum length of 65,535 bytes String Data Type
308 BLOB(size) For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data String Data Type
309 MEDIUMTEXT Holds a string with a maximum length of 16,777,215 characters String Data Type
310 MEDIUMBLOB For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data String Data Type
311 LONGTEXT Holds a string with a maximum length of 4,294,967,295 characters String Data Type
312 LONGBLOB For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data String Data Type
313 ENUM(val1, val2, val3, ...) A string object that can have only one value, chosen from a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the order you enter them String Data Type
314 SET(val1, val2, val3, ...) A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list String Data Type
315 BIT(size) A bit-value type. The number of bits per value is specified in size. The size parameter can hold a value from 1 to 64. The default value for size is 1. Numeric Data Type
316 TINYINT(size) A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255. The size parameter specifies the maximum display width (which is 255) Numeric Data Type
317 BOOL Zero is considered as false, nonzero values are considered as true. Numeric Data Type
318 BOOLEAN Equal to BOOL Numeric Data Type
319 SMALLINT(size) A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535. The size parameter specifies the maximum display width (which is 255) Numeric Data Type
320 MEDIUMINT(size) A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215. The size parameter specifies the maximum display width (which is 255) Numeric Data Type
321 INT(size) A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter specifies the maximum display width (which is 255) Numeric Data Type
322 INTEGER(size) Equal to INT(size) Numeric Data Type
323 BIGINT(size) A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to 18446744073709551615. The size parameter specifies the maximum display width (which is 255) Numeric Data Type
324 FLOAT(size, d) A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions Numeric Data Type
325 FLOAT(p) A floating point number. MySQL uses the p value to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT(). If p is from 25 to 53, the data type becomes DOUBLE() Numeric Data Type
326 DOUBLE(size, d) A normal-size floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter Numeric Data Type
327 DOUBLE PRECISION(size, d) Numeric Data Type
328 DECIMAL(size, d) An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0. Numeric Data Type
329 DEC(size, d) Equal to DECIMAL(size,d) Numeric Data Type
330 DATE A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31' Date and Time Data Type
331 DATETIME(fsp) A date and time combination. Format: YYYY-MM-DD hh:mm:ss. The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. Adding DEFAULT and ON UPDATE in the column definition to get automatic initialization and updating to the current date and time Date and Time Data Type
332 TIMESTAMP(fsp) A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch ('1970-01-01 00:00:00' UTC). Format: YYYY-MM-DD hh:mm:ss. The supported range is from '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC. Automatic initialization and updating to the current date and time can be specified using DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP in the column definition Date and Time Data Type
333 TIME(fsp) A time. Format: hh:mm:ss. The supported range is from '-838:59:59' to '838:59:59' Date and Time Data Type
334 YEAR A year in four-digit format. Values allowed in four-digit format: 1901 to 2155, and 0000.MySQL 8.0 does not support year in two-digit format. Date and Time Data Type
335 sql_variant Stores up to 8,000 bytes of data of various data types, except text, ntext, and timestamp Other Data Type
336 uniqueidentifier Stores a globally unique identifier (GUID) Other Data Type
337 xml Stores XML formatted data. Maximum 2GB Other Data Type
338 cursor Stores a reference to a cursor used for database operations Other Data Type
339 table Stores a result-set for later processing Other Data Type
Sample SQL Statements

Add Auto-Increment Index 'id'

ALTER TABLE users ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD INDEX (id);

Set mySQL Auto-Increment ID Value

ALTER TABLE `table_name` AUTO_INCREMENT=10000

Reset mySQL Auto-Increment ID Value

ALTER TABLE tablename AUTO_INCREMENT = 1

MYSQL Char Sets

ALTER DATABASE database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER DATABASE database CHARACTER SET utf8 COLLATE utf8_unicode_ci;

ALTER TABLE table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

ALTER DATABASE database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

MYSQL Group Data by Time

SELECT HOUR(dt), WEEKDAY(dt), COUNT(*) FROM tbl GROUP BY HOUR(dt), WEEKDAY(dt) ORDER BY HOUR(dt), WEEKDAY(dt);

Syntax I.

AND / OR SELECT column_name(s) FROM table_name WHERE condition AND|OR condition ALTER TABLE ALTER TABLE table_name ADD column_name datatype

Syntax II.

ALTER TABLE table_name DROP COLUMN column_name AS (alias) SELECT column_name AS column_alias FROM table_name

Syntax III.

SELECT column_name FROM table_name AS table_alias BETWEEN SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2 CREATE DATABASE CREATE DATABASE database_name CREATE TABLE CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, ... ) CREATE INDEX CREATE INDEX index_name ON table_name (column_name)

Syntax IV.

CREATE UNIQUE INDEX index_name ON table_name (column_name) CREATE VIEW CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition DELETE DELETE FROM table_name WHERE some_column=some_value

Syntax V.

DELETE FROM table_name

(Note: Deletes the entire table!!)

DELETE * FROM table_name

(Note: Deletes the entire table!!)

DROP DATABASE DROP DATABASE database_name DROP INDEX DROP INDEX table_name.index_name (SQL Server) DROP INDEX index_name ON table_name (MS Access) DROP INDEX index_name (DB2/Oracle) ALTER TABLE table_name DROP INDEX index_name (MySQL) DROP TABLE DROP TABLE table_name EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?) BEGIN --do what needs to be done if exists END ELSE BEGIN --do what needs to be done if not END GROUP BY SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name HAVING SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name HAVING aggregate_function(column_name) operator value IN SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,..) INSERT INTO INSERT INTO table_name VALUES (value1, value2, value3,....)

Syntax VI.

INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,....) INNER JOIN SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name LEFT JOIN SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name RIGHT JOIN SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name FULL JOIN SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name LIKE SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern ORDER BY SELECT column_name(s) FROM table_name ORDER BY column_name [ASC|DESC] SELECT SELECT column_name(s) FROM table_name SELECT * SELECT * FROM table_name SELECT DISTINCT SELECT DISTINCT column_name(s) FROM table_name SELECT INTO SELECT * INTO new_table_name [IN externaldatabase] FROM old_table_name

Syntax VII.

SELECT column_name(s) INTO new_table_name [IN externaldatabase] FROM old_table_name SELECT TOP SELECT TOP number|percent column_name(s) FROM table_name TRUNCATE TABLE TRUNCATE TABLE table_name UNION SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2 UNION ALL SELECT column_name(s) FROM table_name1 UNION ALL SELECT column_name(s) FROM table_name2 UPDATE UPDATE table_name SET column1=value, column2=value,... WHERE some_column=some_value WHERE SELECT column_name(s) FROM table_name WHERE column_name operator value