Raindrops Notion Database

Raindrops Notion Database

88 bookmarks
Newest
Tables and Data | Supabase Docs
Tables and Data | Supabase Docs
Tables are where you store your data. Tables are similar to excel spreadsheets. They contain columns and rows. For example, this table has 3 "columns" (id, name, description) and 4 "rows" of data: idnamedescription1The Phantom MenaceTwo Jedi escape a hostile blockade to find allies and come across a young boy who may bring balance to the Force.2Attack of the ClonesTen years after the invasion of Naboo, the Galactic Republic is facing a Separatist movement.3Revenge of the SithAs Obi-Wan pursues a new threat, Anakin acts as a double agent between the Jedi Council and Palpatine and is lured into a sinister plan to rule the galaxy.4Star WarsLuke Skywalker joins forces with a Jedi Knight, a cocky pilot, a Wookiee and two droids to save the galaxy from the Empire's world-destroying battle station. There are a few important differences from a spreadsheet, but it's a good starting point if you're new to Relational databases. Creating tables# When creating a table, it's best practice to add columns at the same time. You must define the "data type" of each column when it is created. You can add and remove columns at any time after creating a table. Supabase provides several options for creating tables. You can use the Dashboard or create them directly using SQL. We provide a SQL editor within the Dashboard, or you can connect to your database and run the SQL queries yourself. DashboardSQL Go to the Table Editor page in the Dashboard. Click New Table and create a table with the name todos. Click Save. Click New Column and create a column with the name task and type text. Click Save. When naming tables, use lowercase and underscores instead of spaces (e.g., table_name, not Table Name). Columns# You must define the "data type" when you create a column. Data types# Every column is a predefined type. Postgres provides many default types, and you can even design your own (or use extensions) if the default types don't fit your needs. You can use any data type that Postgres supports via the SQL editor. We only support a subset of these in the Table Editor in an effort to keep the experience simple for people with less experience with databases. Show/Hide default data typesNameAliasesDescriptionbigintint8signed eight-byte integerbigserialserial8autoincrementing eight-byte integerbitfixed-length bit stringbit varyingvarbitvariable-length bit stringbooleanboollogical Boolean (true/false)boxrectangular box on a planebyteabinary data (“byte array”)charactercharfixed-length character stringcharacter varyingvarcharvariable-length character stringcidrIPv4 or IPv6 network addresscirclecircle on a planedatecalendar date (year, month, day)double precisionfloat8double precision floating-point number (8 bytes)inetIPv4 or IPv6 host addressintegerint, int4signed four-byte integerinterval [ fields ]time spanjsontextual JSON datajsonbbinary JSON data, decomposedlineinfinite line on a planelsegline segment on a planemacaddrMAC (Media Access Control) addressmacaddr8MAC (Media Access Control) address (EUI-64 format)moneycurrency amountnumericdecimalexact numeric of selectable precisionpathgeometric path on a planepg_lsnPostgres Log Sequence Numberpg_snapshotuser-level transaction ID snapshotpointgeometric point on a planepolygonclosed geometric path on a planerealfloat4single precision floating-point number (4 bytes)smallintint2signed two-byte integersmallserialserial2autoincrementing two-byte integerserialserial4autoincrementing four-byte integertextvariable-length character stringtime [ without time zone ]time of day (no time zone)time with time zonetimetztime of day, including time zonetimestamp [ without time zone ]date and time (no time zone)timestamp with time zonetimestamptzdate and time, including time zonetsquerytext search querytsvectortext search documenttxid_snapshotuser-level transaction ID snapshot (deprecated; see pg_snapshot)uuiduniversally unique identifierxmlXML data You can "cast" columns from one type to another, however there can be some incompatibilities between types. For example, if you cast a timestamp to a date, you will lose all the time information that was previously saved. Primary keys# A table can have a "primary key" - a unique identifier for every row of data. A few tips for Primary Keys: It's recommended to create a Primary Key for every table in your database. You can use any column as a primary key, as long as it is unique for every row. It's common to use a uuid type or a numbered identity column as your primary key. 1create table movies (2 id bigint generated always as identity primary key3); In the example above, we have: created a column called id assigned the data type bigint instructed the database that this should be generated always as identity, which means that Postgres will automatically assign a unique number to this column. Because it's unique, we can also use it as our primary key. We could also use generated by default as identity, which would allow us to insert our own unique values.
·supabase.com·
Tables and Data | Supabase Docs