treffynnon / sqlstyle.guide

A consistent code style guide for SQL to ensure legible and maintainable projects

Home Page:https://www.sqlstyle.guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add suggested data types section

Alxe opened this issue · comments

Currently designing a Sqlite schema for an university assignment, wanted a few pointers on writing SQL scripts when I found this nice website.

After reading the "Create table" section, concretly:

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.

I wondered which data types are vendor specific and which are *not*, as I've worked in the past with MySQL, MS SQL, Sqlite and now also PostgreSQL, and understood about "int, char, varchar" but now I've learned about "Numeric", "Decimal", geospatial types and the like.

So, maybe someone with greater experise could redact a list, or better, a table of which datatypes are the most supported in general and which keyword do they use? It could be added as a new HTML page rather than in the main document.

Regard,
Alejandro

I like this idea. I don't have such a list at the moment, but I think I should be able to put something together.

I think this might be something along the lines of the current reserved keywords appendix at the base of the guide.

I wonder if this would be enough for the column data types list or if I've missed anything.

Character types:

  • CHAR
  • CLOB
  • VARCHAR

Numeric types

  • Exact numeric types
    • BIGINT
    • DECIMAL
    • DECFLOAT
    • INTEGER
    • NUMERIC
    • SMALLINT
  • Approximate numeric types
    • DOUBLE PRECISION
    • FLOAT
    • REAL

Datetime types

  • DATE
  • TIME
  • TIMESTAMP

Binary types:

  • BINARY
  • BLOB
  • VARBINARY

Additional types

  • Boolean
  • INTERVAL
  • XML