· 9 years ago · Jan 23, 2017, 10:26 PM
1# MySQL guide - Activisme-BE
2
3## Overview
4
5These guidelines are designed to be compatible with Joe Celko's SQL Programming Style book to make adoption for teams who
6already read that book easier. This guide is a little more opinionated in some areas and in others a little more relaxed.
7It is certainly more succint where Celko's book contains anecdotes and reasoning behind each rule thoughtful prose.
8
9It is easy to include this guide in Markdown format as a part of a project's code base or reference it here for anyone on the project to
10freely read - much harder with a physical book.
11
12## General
13
14### Do
15
16- Use consistent and descriptive identifiers and names.
17- Make judicious use of white space and indentation to make easier to read.
18- Store ISO-8601 complaint time and data information `(YYYY-MM-DD HH:MM:SS.SSSSS)`.
19- Try to use only standard SQL functions instead of vendor speicific functions for reasons of portability.
20- Keep code succinct and devoid of redundant SQL - such as unnecessary quoting or parentheses of `WHERE` clauses that can otherwise be derived.
21- Include comments in SQL code where necessary. Use the C style opining `/*` and closing `*/` where possible otherwise precede comments with `--` and finish then with a new line.
22
23#### Examples
24
25```sql
26SELECT file_hash -- stored ssdeep hash
27 FROM file_system
28 WHERE file_name = '.vimrc';
29```
30
31```sql
32/* Updating the file record after writing to the file */
33UPDATE file_system
34 SET file_modified_data = '1980-02-22 13:19:01.00000',
35 file_size = 209732
36 WHERE file_name = '.vimrc';
37```
38
39### Avoid
40
41- CamelCase - it is difficult to scan quickly.
42- Descriptive prefixes of Hungarian notation as `sp_` of `tbl`.
43- Plurals - use the more natural collective term where possible intead. For example `staff` instead of `employees` or `people` instead of `individuals`.
44- Quetd indentifiers - if you must use them stick to SQL92 double quotes for portability (you may need to configure your SQL server to support this depending on vendor).
45- Object oriented design principles should not be applied to SQL or database structures.
46
47## Naming conventions
48
49### General
50
51- Ensure the name is unique and does not exist as reserved keyword.
52- Keep the length to a maximum of 30 bytes - in practice this is 30 characters unless you are using multi-byte character set.
53- Names must begin with a letter and may not end with an underscore.
54- Only use letters, numbers and underscores in names.
55- Avoid the use of multiple consecutive underscores - these can be hard to read.
56- Use underscores where you would naturally include a space in the name (first name becomes `first_name`).
57- Avoid abbreviations and if you have to use them make sure they are commonly understood.
58
59#### Examples
60
61```sql
62SELECT first_name
63 FROM staff;
64```
65
66### Tables
67
68- Use a collective name or, less ideally, a plural form. For example (in order of preference) `staff` and `employees`.
69- Do not prefix with `tbl` or any other such descriptive prefix or Hungarian notation.
70- Never give a table the same name as one of its columns and vice versa.
71- Avoid, where possible, concatenating two table names together to create the name of a relationship table. Rather then `cars_mechanics` prefer `services`.
72
73### Columns
74
75- Always use the singular name.
76- Where possible avoid simply using `id` as the primary identifier for the table.
77- Do not add a column with the same name as its table and vice versa.
78- Always use lowercase except where it may make sense not to such as proper nouns.
79
80### Aliasing or correlations
81
82- Should relate in some way to the object or expression they are aliasing.
83- As a rule of thumb the correlation name should be the first letter of each word in the object's name.
84- If there is already a correlation with the same name then append a number.
85- Always include the `AS` keyword - makes it easier to read as it is explicit.
86- For computed data (`SUM()` or `AVG()`) use the name you would give it were it a column defined in the schema.
87
88#### Examples
89
90```sql
91SELECT first_name AS fn
92 FROM staff AS s1
93 JOIN students AS s2
94 ON s2.mentor_id = s1.staff_num;
95```
96
97```sql
98SELECT SUM(s.monitor_tally) AS monitor_total
99 FROM staff as s;
100```
101
102### Stored procedures
103
104 - The name must contain a verb.
105 - Do not prefix with `sp_` or any other such descriptive prefix or Hungarian notation.
106
107### Uniform suffixes
108
109The following suffixes have a universal meaning ensuring the columns canbe read and understood easily from SQL code. Use the correct suffix where appropriate.
110
111- `_id` - A unique identifier such as a column that is a primary key.
112- `_status` - flag value or some other status of any type such as `publication_status`.
113- `_total` - the total or sum of a collection of values.
114- `_num` - denotes the field contains any kind of number.
115- `_name` - signifies a name such as `first_name`.
116- `_seg` - contains a contiguous sequence of values.
117- `_date` - denotes a column that contains the date of something.
118- `_tally` - a count
119- `_size` - the size of something such as a file size or clothing.
120- `_addr` - an address for the record could be physical or intangible such as `ip_addr`.
121
122## Query syntax
123
124### Reserved keywords
125
126Always use uppercase for the reserved keywords like `SELECT` and `WHERE`.
127
128It is best to avoid the abbreviated keywords and use the full length ones where available (prefer `ABSOLUTE` to `ABS`).
129
130Do not use database server specific keywords where an ANSI SQL keyword already exists performing the same function.
131This helps to make code more portable.
132
133#### Example
134
135```sql
136SELECT model_num
137 FROM phones AS p
138 WHERE p.release_data > '2014-09-30';
139```
140
141### White space
142
143To make the code easier to read it is important that the correct compliment of spacing is used. Do not crowd code or remove natural language spaces.
144
145### Spaces
146
147Spaces should be used to line up the code so that the root keywords all end on the same character boundary.
148This forms a river down the middle making it easy for the readers eye to scan over the code and seperate the keywords
149from the implementation detail. Rivers are bad in typography, but helpful there.
150
151#### Example
152
153```sql
154SELECT f.average_height, f.average_diameter
155 FROM flora AS f
156 WHERE f.species_name = 'Banksia'
157 OR f.species_name = 'Sheoak'
158 OR f.species_name = 'Wattle';
159```
160
161Notice that `SELECT`, `FROM`, etc. are all right aligned while the actual column names and implementation specific details are left aligned.
162
163Although not exhaustive always include spaces:
164
165- before and after equals (`=`)
166- after commas (`,`)
167- surrounding apostrophes (`'`) where not within parentheses or with trailing comma or semicolon.
168
169#### Example
170
171```sql
172SELECT a.title, a.release_date, a.recording_date
173 FROM albums AS a
174 WHERE a.title = 'Charcoal Lane'
175 OR a.title = 'The New Danger';
176```
177
178### Line spacing
179
180Always include newlines/vertical space:
181
182- before `AND` or `OR`
183- after semicolons to sperate queries for easier reading.
184- after each keyword definition.
185- after a comma when seperating multiple columns into logical groups
186- to seperate code into related sections, which helps to ease the readability of large chuncks of code.
187
188Keeping all the keywords aligned to the righthand side and the values left aligned creates a uniform gap down
189the middle of query. It makes it much easier to scan the query definition over quickly too.
190
191#### Example
192
193```sql
194INSERT INTO albums (title, release_date, recording_date)
195VALUES ('Charcoal Lane', '1990-01-01 01:01:01.00000', '1990-01-01 01:01:01.00000'),
196 ('The New Danger', '2008-01-01 01:01:01.00000', '1990-01-01 01:01:01.00000');
197```
198
199```sql
200UPDATE albums
201 SET release_date = '1990-01-01 01:01:01.00000'
202 WHERE title = 'The New Danger';
203```
204
205```sql
206SELECT a.title,
207 a.release_date, a.recording_date, a.production_date -- grouped dates together
208 FROM albums AS a
209 WHERE a.title = 'Charcoal Lane'
210 OR a.title = 'The New Danger';
211```
212
213## Indentation
214
215To ensure that SQL is readable it is important that standards of indentation are followed.
216
217### Joins
218
219Joins should be indented to the other side of the river and grouped with the new line where necessary.
220
221#### Example
222
223```sql
224SELECT r.last_name
225 FROM riders AS r
226 INNER JOIN bikes AS b
227 ON r.bike_vin_num = b.vin_num
228 AND b.engines > 2
229
230 INNER JOIN crew AS c
231 ON r.crew_chief_last_name = c.last_name
232 AND c.chief = 'Y';
233```
234
235### Subqueries
236
237Subqueries should also be aligned to the right side of the river and then laid out using the same style as any other query.
238Sometimes it will make sense to have the closing parenthesis on a new line at the same character position as it’s opening partner—this is especially true where you have nested subqueries.
239
240#### Example
241
242```sql
243SELECT r.last_name,
244 (SELECT MAX(YEAR(championship_date))
245 FROM champions AS c
246 WHERE c.last_name = r.last_name
247 AND c.confirmed = 'Y') AS last_championship_year
248 FROM riders AS r
249 WHERE r.last_name IN
250 (SELECT c.last_name
251 FROM champions AS c
252 WHERE YEAR(championship_date) > '2008'
253 AND c.confirmed = 'Y');
254```
255
256### Preferred formalisms
257
258- Make use of `BETWEEN` where possible instead of combining multiple statements with `AND`.
259- Similarly use `IN()` instead of multiple `OR` clauses.
260- Where a value needs to be interpreted before leaving the database use the use the `CASE` expression. `CASE` statements can be nested to form more complex logical structures.
261- Avoid the use of `UNION` clauses and temporary tables where possible. If the schema can be optimised to remove the reliance on these features the it most likely should be.
262
263#### Example
264
265```sql
266SELECT CASE postcode
267 WHEN 'BN1' THEN 'Brighton'
268 WHEN 'EH1' THEN 'Edinburgh'
269 END AS city
270 FROM office_locations
271 WHERE country = 'United Kingdom'
272 AND opening_time BETWEEN 8 AND 9
273 AND postcode IN ('EH1', 'BN1', 'NN1', 'KW1')
274```
275
276## Create syntax
277
278When declaring schema information it is also important to maintain human readable code. To facilitate this
279ensure the column definitions are ordered and grouped where it makes sense to do so.
280
281Indent column definitions by four (4) spaces within the `CREATE` definition.
282
283### Choosing data types
284
285- Where possible do not use vendor specific data types - these are not portable and may not be available in older versions of the same vendor's software.
286- Only use `REAL` or `FLOAT` types where it is strictly necessary for floating point mathematics otherwise prefer `NUMERIC` and `DECIMAL` at all times. Floating point rounding errors are a nuisance!
287
288### Specifying default values
289
290- The default value must be the same type as the column - if a column is declared a `DECIMAL` do not provide an `INTEGER` default value.
291- Default values must follow the data type declaration and come before any `NOT NULL` statements.
292
293## Constraints and keys
294
295Constraints and their subset, keys, are a very important component of any database definition. They can quickly become very difficult to read and reason about though so it is
296important that a standard set of guidelines are followed.
297
298### Choosing keys
299
300Deciding the column(s) that will form the keys in the definition should be a carefully considered activity as it will effect performance and data integrity.
301
3021. The key sho)uld be unique to some degree.
3032. Consistency in terms of data type for the value across the schema and a lower likelihood of this changing in the future.
3043. Can the value be validatied against a standard format (such as published by ISO)? Encouraging conformity to point 2.
3054. Keeping the key as simple as possible whilst not being scared to use compound keys where necessary.
306
307It is a reasoned and considered balancing act to be performed at the definition of a database. Should requirements evolve in the future it is possible to make changes to the definitions to keep them up to date.
308
309### Defining constraints
310
311Once the keys are decided it is possible to define them in the system using constraints along with field value validation.
312
313#### General
314
315- Tables must have at least one key to be complete and useful.
316- Constraints should be given a custom name expecting `UNIQUE`, `PRIMARY KEY`, and `FOREIGN KEY` where the database vendor will generally sufficiently intelligible names automatically.
317
318#### Layout and order
319
320- Specify the primary key first right after the `CREATE TABLE` statement.
321- Constraints should be defined directly beneath the column they correspond to. Indent the constraint so that it aligns to the right of the column name.
322- If it is a multi-column constraint then consider putting it as close to both column definitions as possible and where this is difficult as a last resort include them at the end of the CREATE TABLE definition.
323- If it is a table level constraint that applies to the entire table then it should also appear at the end.
324- Use alphabetical order where ON DELETE comes before ON UPDATE.
325- If it make senses to do so align each aspect of the query on the same character position. For example all NOT NULL definitions could start at the same character position. This is not hard and fast, but it certainly makes the code much easier to scan and read.
326
327#### Validation
328
329- Use `LIKE` and `SIMILAR` TO constraints to ensure the integrity of strings where the format is known.
330- Where the ultimate range of a numerical value is known it must be written as a range `CHECK()` to prevent incorrect values entering the database or the silent truncation of data too large to fit the column definition. In the least it should check that the value is greater than zero in most cases.
331- `CHECK()` constraints should be kept in separate clauses to ease debugging.
332
333#### Example
334
335```sql
336CREATE TABLE staff (
337 PRIMARY KEY (staff_num),
338 staff_num INT(5) NOT NULL,
339 first_name VARCHAR(100) NOT NULL,
340 pens_in_drawer INT(2) NOT NULL,
341 CONSTRAINT pens_in_drawer_range
342 CHECK(pens_in_drawer >= 1 AND pens_in_drawer < 100)
343);
344```
345
346## Designs to avoid
347
348- Object oriented design principles do not effectively translate to relational database designs—avoid this pitfall.
349- Placing the value in one column and the units in another column. The column should make the units self evident to prevent the requirement to combine columns again later in the application. Use `CHECK()` to ensure valid data is inserted into the column.
350- EAV (Entity Attribute Value) tables—use a specialist product intended for handling such schema-less data instead.
351- Splitting up data that should be in one table across many because of arbitrary concerns such as time-based archiving or location in a multi-national organisation. Later queries must then work across multiple tables with `UNION` rather than just simply querying one table.µ
352
353## Appendix
354
355### Reserved keyword reference
356
357A list of ANSI SQL (92, 99 and 2003), MySQL 3 to 5.x, PostgreSQL 8.1, MS SQL Server 2000, MS ODBC and Oracle 10.2 reserved keywords.
358
359```sql
360A
361ABORT
362ABS
363ABSOLUTE
364ACCESS
365ACTION
366ADA
367ADD
368ADMIN
369AFTER
370AGGREGATE
371ALIAS
372ALL
373ALLOCATE
374ALSO
375ALTER
376ALWAYS
377ANALYSE
378ANALYZE
379AND
380ANY
381ARE
382ARRAY
383AS
384ASC
385ASENSITIVE
386ASSERTION
387ASSIGNMENT
388ASYMMETRIC
389AT
390ATOMIC
391ATTRIBUTE
392ATTRIBUTES
393AUDIT
394AUTHORIZATION
395AUTO_INCREMENT
396AVG
397AVG_ROW_LENGTH
398BACKUP
399BACKWARD
400BEFORE
401BEGIN
402BERNOULLI
403BETWEEN
404BIGINT
405BINARY
406BIT
407BIT_LENGTH
408BITVAR
409BLOB
410BOOL
411BOOLEAN
412BOTH
413BREADTH
414BREAK
415BROWSE
416BULK
417BY
418C
419CACHE
420CALL
421CALLED
422CARDINALITY
423CASCADE
424CASCADED
425CASE
426CAST
427CATALOG
428CATALOG_NAME
429CEIL
430CEILING
431CHAIN
432CHANGE
433CHAR
434CHAR_LENGTH
435CHARACTER
436CHARACTER_LENGTH
437CHARACTER_SET_CATALOG
438CHARACTER_SET_NAME
439CHARACTER_SET_SCHEMA
440CHARACTERISTICS
441CHARACTERS
442CHECK
443CHECKED
444CHECKPOINT
445CHECKSUM
446CLASS
447CLASS_ORIGIN
448CLOB
449CLOSE
450CLUSTER
451CLUSTERED
452COALESCE
453COBOL
454COLLATE
455COLLATION
456COLLATION_CATALOG
457COLLATION_NAME
458COLLATION_SCHEMA
459COLLECT
460COLUMN
461COLUMN_NAME
462COLUMNS
463COMMAND_FUNCTION
464COMMAND_FUNCTION_CODE
465COMMENT
466COMMIT
467COMMITTED
468COMPLETION
469COMPRESS
470COMPUTE
471CONDITION
472CONDITION_NUMBER
473CONNECT
474CONNECTION
475CONNECTION_NAME
476CONSTRAINT
477CONSTRAINT_CATALOG
478CONSTRAINT_NAME
479CONSTRAINT_SCHEMA
480CONSTRAINTS
481CONSTRUCTOR
482CONTAINS
483CONTAINSTABLE
484CONTINUE
485CONVERSION
486CONVERT
487COPY
488CORR
489CORRESPONDING
490COUNT
491COVAR_POP
492COVAR_SAMP
493CREATE
494CREATEDB
495CREATEROLE
496CREATEUSER
497CROSS
498CSV
499CUBE
500CUME_DIST
501CURRENT
502CURRENT_DATE
503CURRENT_DEFAULT_TRANSFORM_GROUP
504CURRENT_PATH
505CURRENT_ROLE
506CURRENT_TIME
507CURRENT_TIMESTAMP
508CURRENT_TRANSFORM_GROUP_FOR_TYPE
509CURRENT_USER
510CURSOR
511CURSOR_NAME
512CYCLE
513DATA
514DATABASE
515DATABASES
516DATE
517DATETIME
518DATETIME_INTERVAL_CODE
519DATETIME_INTERVAL_PRECISION
520DAY
521DAY_HOUR
522DAY_MICROSECOND
523DAY_MINUTE
524DAY_SECOND
525DAYOFMONTH
526DAYOFWEEK
527DAYOFYEAR
528DBCC
529DEALLOCATE
530DEC
531DECIMAL
532DECLARE
533DEFAULT
534DEFAULTS
535DEFERRABLE
536DEFERRED
537DEFINED
538DEFINER
539DEGREE
540DELAY_KEY_WRITE
541DELAYED
542DELETE
543DELIMITER
544DELIMITERS
545DENSE_RANK
546DENY
547DEPTH
548DEREF
549DERIVED
550DESC
551DESCRIBE
552DESCRIPTOR
553DESTROY
554DESTRUCTOR
555DETERMINISTIC
556DIAGNOSTICS
557DICTIONARY
558DISABLE
559DISCONNECT
560DISK
561DISPATCH
562DISTINCT
563DISTINCTROW
564DISTRIBUTED
565DIV
566DO
567DOMAIN
568DOUBLE
569DROP
570DUAL
571DUMMY
572DUMP
573DYNAMIC
574DYNAMIC_FUNCTION
575DYNAMIC_FUNCTION_CODE
576EACH
577ELEMENT
578ELSE
579ELSEIF
580ENABLE
581ENCLOSED
582ENCODING
583ENCRYPTED
584END
585END-EXEC
586ENUM
587EQUALS
588ERRLVL
589ESCAPE
590ESCAPED
591EVERY
592EXCEPT
593EXCEPTION
594EXCLUDE
595EXCLUDING
596EXCLUSIVE
597EXEC
598EXECUTE
599EXISTING
600EXISTS
601EXIT
602EXP
603EXPLAIN
604EXTERNAL
605EXTRACT
606FALSE
607FETCH
608FIELDS
609FILE
610FILLFACTOR
611FILTER
612FINAL
613FIRST
614FLOAT
615FLOAT4
616FLOAT8
617FLOOR
618FLUSH
619FOLLOWING
620FOR
621FORCE
622FOREIGN
623FORTRAN
624FORWARD
625FOUND
626FREE
627FREETEXT
628FREETEXTTABLE
629FREEZE
630FROM
631FULL
632FULLTEXT
633FUNCTION
634FUSION
635G
636GENERAL
637GENERATED
638GET
639GLOBAL
640GO
641GOTO
642GRANT
643GRANTED
644GRANTS
645GREATEST
646GROUP
647GROUPING
648HANDLER
649HAVING
650HEADER
651HEAP
652HIERARCHY
653HIGH_PRIORITY
654HOLD
655HOLDLOCK
656HOST
657HOSTS
658HOUR
659HOUR_MICROSECOND
660HOUR_MINUTE
661HOUR_SECOND
662IDENTIFIED
663IDENTITY
664IDENTITY_INSERT
665IDENTITYCOL
666IF
667IGNORE
668ILIKE
669IMMEDIATE
670IMMUTABLE
671IMPLEMENTATION
672IMPLICIT
673IN
674INCLUDE
675INCLUDING
676INCREMENT
677INDEX
678INDICATOR
679INFILE
680INFIX
681INHERIT
682INHERITS
683INITIAL
684INITIALIZE
685INITIALLY
686INNER
687INOUT
688INPUT
689INSENSITIVE
690INSERT
691INSERT_ID
692INSTANCE
693INSTANTIABLE
694INSTEAD
695INT
696INT1
697INT2
698INT3
699INT4
700INT8
701INTEGER
702INTERSECT
703INTERSECTION
704INTERVAL
705INTO
706INVOKER
707IS
708ISAM
709ISNULL
710ISOLATION
711ITERATE
712JOIN
713K
714KEY
715KEY_MEMBER
716KEY_TYPE
717KEYS
718KILL
719LANCOMPILER
720LANGUAGE
721LARGE
722LAST
723LAST_INSERT_ID
724LATERAL
725LEADING
726LEAST
727LEAVE
728LEFT
729LENGTH
730LESS
731LEVEL
732LIKE
733LIMIT
734LINENO
735LINES
736LISTEN
737LN
738LOAD
739LOCAL
740LOCALTIME
741LOCALTIMESTAMP
742LOCATION
743LOCATOR
744LOCK
745LOGIN
746LOGS
747LONG
748LONGBLOB
749LONGTEXT
750LOOP
751LOW_PRIORITY
752LOWER
753M
754MAP
755MATCH
756MATCHED
757MAX
758MAX_ROWS
759MAXEXTENTS
760MAXVALUE
761MEDIUMBLOB
762MEDIUMINT
763MEDIUMTEXT
764MEMBER
765MERGE
766MESSAGE_LENGTH
767MESSAGE_OCTET_LENGTH
768MESSAGE_TEXT
769METHOD
770MIDDLEINT
771MIN
772MIN_ROWS
773MINUS
774MINUTE
775MINUTE_MICROSECOND
776MINUTE_SECOND
777MINVALUE
778MLSLABEL
779MOD
780MODE
781MODIFIES
782MODIFY
783MODULE
784MONTH
785MONTHNAME
786MORE
787MOVE
788MULTISET
789MUMPS
790MYISAM
791NAME
792NAMES
793NATIONAL
794NATURAL
795NCHAR
796NCLOB
797NESTING
798NEW
799NEXT
800NO
801NO_WRITE_TO_BINLOG
802NOAUDIT
803NOCHECK
804NOCOMPRESS
805NOCREATEDB
806NOCREATEROLE
807NOCREATEUSER
808NOINHERIT
809NOLOGIN
810NONCLUSTERED
811NONE
812NORMALIZE
813NORMALIZED
814NOSUPERUSER
815NOT
816NOTHING
817NOTIFY
818NOTNULL
819NOWAIT
820NULL
821NULLABLE
822NULLIF
823NULLS
824NUMBER
825NUMERIC
826OBJECT
827OCTET_LENGTH
828OCTETS
829OF
830OFF
831OFFLINE
832OFFSET
833OFFSETS
834OIDS
835OLD
836ON
837ONLINE
838ONLY
839OPEN
840OPENDATASOURCE
841OPENQUERY
842OPENROWSET
843OPENXML
844OPERATION
845OPERATOR
846OPTIMIZE
847OPTION
848OPTIONALLY
849OPTIONS
850OR
851ORDER
852ORDERING
853ORDINALITY
854OTHERS
855OUT
856OUTER
857OUTFILE
858OUTPUT
859OVER
860OVERLAPS
861OVERLAY
862OVERRIDING
863OWNER
864PACK_KEYS
865PAD
866PARAMETER
867PARAMETER_MODE
868PARAMETER_NAME
869PARAMETER_ORDINAL_POSITION
870PARAMETER_SPECIFIC_CATALOG
871PARAMETER_SPECIFIC_NAME
872PARAMETER_SPECIFIC_SCHEMA
873PARAMETERS
874PARTIAL
875PARTITION
876PASCAL
877PASSWORD
878PATH
879PCTFREE
880PERCENT
881PERCENT_RANK
882PERCENTILE_CONT
883PERCENTILE_DISC
884PLACING
885PLAN
886PLI
887POSITION
888POSTFIX
889POWER
890PRECEDING
891PRECISION
892PREFIX
893PREORDER
894PREPARE
895PREPARED
896PRESERVE
897PRIMARY
898PRINT
899PRIOR
900PRIVILEGES
901PROC
902PROCEDURAL
903PROCEDURE
904PROCESS
905PROCESSLIST
906PUBLIC
907PURGE
908QUOTE
909RAID0
910RAISERROR
911RANGE
912RANK
913RAW
914READ
915READS
916READTEXT
917REAL
918RECHECK
919RECONFIGURE
920RECURSIVE
921REF
922REFERENCES
923REFERENCING
924REGEXP
925REGR_AVGX
926REGR_AVGY
927REGR_COUNT
928REGR_INTERCEPT
929REGR_R2
930REGR_SLOPE
931REGR_SXX
932REGR_SXY
933REGR_SYY
934REINDEX
935RELATIVE
936RELEASE
937RELOAD
938RENAME
939REPEAT
940REPEATABLE
941REPLACE
942REPLICATION
943REQUIRE
944RESET
945RESIGNAL
946RESOURCE
947RESTART
948RESTORE
949RESTRICT
950RESULT
951RETURN
952RETURNED_CARDINALITY
953RETURNED_LENGTH
954RETURNED_OCTET_LENGTH
955RETURNED_SQLSTATE
956RETURNS
957REVOKE
958RIGHT
959RLIKE
960ROLE
961ROLLBACK
962ROLLUP
963ROUTINE
964ROUTINE_CATALOG
965ROUTINE_NAME
966ROUTINE_SCHEMA
967ROW
968ROW_COUNT
969ROW_NUMBER
970ROWCOUNT
971ROWGUIDCOL
972ROWID
973ROWNUM
974ROWS
975RULE
976SAVE
977SAVEPOINT
978SCALE
979SCHEMA
980SCHEMA_NAME
981SCHEMAS
982SCOPE
983SCOPE_CATALOG
984SCOPE_NAME
985SCOPE_SCHEMA
986SCROLL
987SEARCH
988SECOND
989SECOND_MICROSECOND
990SECTION
991SECURITY
992SELECT
993SELF
994SENSITIVE
995SEPARATOR
996SEQUENCE
997SERIALIZABLE
998SERVER_NAME
999SESSION
1000SESSION_USER
1001SET
1002SETOF
1003SETS
1004SETUSER
1005SHARE
1006SHOW
1007SHUTDOWN
1008SIGNAL
1009SIMILAR
1010SIMPLE
1011SIZE
1012SMALLINT
1013SOME
1014SONAME
1015SOURCE
1016SPACE
1017SPATIAL
1018SPECIFIC
1019SPECIFIC_NAME
1020SPECIFICTYPE
1021SQL
1022SQL_BIG_RESULT
1023SQL_BIG_SELECTS
1024SQL_BIG_TABLES
1025SQL_CALC_FOUND_ROWS
1026SQL_LOG_OFF
1027SQL_LOG_UPDATE
1028SQL_LOW_PRIORITY_UPDATES
1029SQL_SELECT_LIMIT
1030SQL_SMALL_RESULT
1031SQL_WARNINGS
1032SQLCA
1033SQLCODE
1034SQLERROR
1035SQLEXCEPTION
1036SQLSTATE
1037SQLWARNING
1038SQRT
1039SSL
1040STABLE
1041START
1042STARTING
1043STATE
1044STATEMENT
1045STATIC
1046STATISTICS
1047STATUS
1048STDDEV_POP
1049STDDEV_SAMP
1050STDIN
1051STDOUT
1052STORAGE
1053STRAIGHT_JOIN
1054STRICT
1055STRING
1056STRUCTURE
1057STYLE
1058SUBCLASS_ORIGIN
1059SUBLIST
1060SUBMULTISET
1061SUBSTRING
1062SUCCESSFUL
1063SUM
1064SUPERUSER
1065SYMMETRIC
1066SYNONYM
1067SYSDATE
1068SYSID
1069SYSTEM
1070SYSTEM_USER
1071TABLE
1072TABLE_NAME
1073TABLES
1074TABLESAMPLE
1075TABLESPACE
1076TEMP
1077TEMPLATE
1078TEMPORARY
1079TERMINATE
1080TERMINATED
1081TEXT
1082TEXTSIZE
1083THAN
1084THEN
1085TIES
1086TIME
1087TIMESTAMP
1088TIMEZONE_HOUR
1089TIMEZONE_MINUTE
1090TINYBLOB
1091TINYINT
1092TINYTEXT
1093TO
1094TOAST
1095TOP
1096TOP_LEVEL_COUNT
1097TRAILING
1098TRAN
1099TRANSACTION
1100TRANSACTION_ACTIVE
1101TRANSACTIONS_COMMITTED
1102TRANSACTIONS_ROLLED_BACK
1103TRANSFORM
1104TRANSFORMS
1105TRANSLATE
1106TRANSLATION
1107TREAT
1108TRIGGER
1109TRIGGER_CATALOG
1110TRIGGER_NAME
1111TRIGGER_SCHEMA
1112TRIM
1113TRUE
1114TRUNCATE
1115TRUSTED
1116TSEQUAL
1117TYPE
1118UESCAPE
1119UID
1120UNBOUNDED
1121UNCOMMITTED
1122UNDER
1123UNDO
1124UNENCRYPTED
1125UNION
1126UNIQUE
1127UNKNOWN
1128UNLISTEN
1129UNLOCK
1130UNNAMED
1131UNNEST
1132UNSIGNED
1133UNTIL
1134UPDATE
1135UPDATETEXT
1136UPPER
1137USAGE
1138USE
1139USER
1140USER_DEFINED_TYPE_CATALOG
1141USER_DEFINED_TYPE_CODE
1142USER_DEFINED_TYPE_NAME
1143USER_DEFINED_TYPE_SCHEMA
1144USING
1145UTC_DATE
1146UTC_TIME
1147UTC_TIMESTAMP
1148VACUUM
1149VALID
1150VALIDATE
1151VALIDATOR
1152VALUE
1153VALUES
1154VAR_POP
1155VAR_SAMP
1156VARBINARY
1157VARCHAR
1158VARCHAR2
1159VARCHARACTER
1160VARIABLE
1161VARIABLES
1162VARYING
1163VERBOSE
1164VIEW
1165VOLATILE
1166WAITFOR
1167WHEN
1168WHENEVER
1169WHERE
1170WHILE
1171WIDTH_BUCKET
1172WINDOW
1173WITH
1174WITHIN
1175WITHOUT
1176WORK
1177WRITE
1178WRITETEXT
1179X509
1180XOR
1181YEAR
1182YEAR_MONTH
1183ZEROFILL
1184ZONE
1185```