diff options
| author | Kitzunu <24550914+Kitzunu@users.noreply.github.com> | 2021-05-08 01:38:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-08 01:38:15 +0200 |
| commit | 5ad0849fdd87d45d0db58a98867942a42458f1a4 (patch) | |
| tree | 069e1462f62c47902f60a397e5300cf8a8b99a10 /docs | |
| parent | c3944bd1e334501073a3451ee3b4f954ca2038c2 (diff) | |
| download | wiki-5ad0849fdd87d45d0db58a98867942a42458f1a4.tar.gz wiki-5ad0849fdd87d45d0db58a98867942a42458f1a4.tar.bz2 wiki-5ad0849fdd87d45d0db58a98867942a42458f1a4.zip | |
chore(sql-standards): Add Tables and Columns standards (#470)
* chore(sql-standards): Add Tables and Columns standards
* Update sql-standards.md
* Update sql-standards.md
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/sql-standards.md | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/docs/sql-standards.md b/docs/sql-standards.md index c2d0da5..6e1d2f9 100644 --- a/docs/sql-standards.md +++ b/docs/sql-standards.md @@ -137,6 +137,51 @@ UPDATE `creature_template` SET `mechanic_immune_mask`=`mechanic_immune_mask`|64| UPDATE `creature_template` SET `mechanic_immune_mask`=`mechanic_immune_mask`&~(64|256|1024) WHERE `entry` = 7727; ``` -### Note for SQL reviewer +## Tables and Columns + +### Integers + +We do not define the width of an integer when we create new columns. (Width is deprecated in later versions of MySQL 8) + +``` +TINYINT(M) -> TINYINT +SMALLINT(M) -> SMALLINT +INT(M) -> INT +MEDIUMINT(M) -> MEDIUMINT +BIGINT(M) -> BIGINT + +BOOL -> Never used, synonym for TINYINT. 0 = false <>0 = true +``` + +### Float, Double, Decimal + +These data types cannot be UNSIGNED and therefore we use CHECK CONSTRAINTS instead. (UNSIGNED Float, Double, Decimal is deprecated in later versions of MySQL 8) + +``` +FLOAT UNSIGNED -> CHECK (`column`>=0) +``` + +### Character Encoding + +We use UTF8MB4 where you would previously use UTF8 or UTF8MB3. (utf8 is an alias and utf8mb3 is deprecated in later versions of MySQL 8) + +``` +utf8 -> utf8mb4 +utf8mb3 -> utf8mb4 + +This also applies to utf8_unicode_ci etc. +``` + +### Check Constraints + +You can see [here](https://github.com/Azerothcore/azerothcore-wotlk/blob/master/data/sql/base/db_auth/realmlist.sql) how check contraints are made. + +All active Check Constraints can be found by using this query: + +```sql +SELECT * FROM information_schema.CHECK_CONSTRAINTS; +``` + +## Note for SQL reviewer When we work with GUID's, make sure that we use as low entries as possible to fill out the gaps in the database. This can easily be done with tools like [Unused GUID Searcher](https://github.com/azerothcore/unused-guid-search). |
