Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
-- Numeric types CREATE TABLE numeric_examples ( small_num SMALLINT, -- -32768 to 32767 regular_num INTEGER, -- ~2.1 billion large_num BIGINT, -- ~9.2 * 10^18 auto_id SERIAL, -- auto-increment INTEGER big_auto BIGSERIAL, -- auto-increment BIGINT -- Exact decimal (best for money) price NUMERIC(10, 2), -- up to 99999999.99 tax_rate NUMERIC(5, 4), -- e.g. 0.0875 -- Floating point (approximate) ratio DOUBLE PRECISION, score REAL ); -- String types CREATE TABLE string_examples ( code CHAR(3), -- fixed length, padded with spaces username VARCHAR(50), -- variable, max 50 chars bio TEXT, -- unlimited length -- Enum type status TEXT CHECK (status IN ('active', 'inactive', 'banned')) ); -- Named ENUM type CREATE TYPE mood AS ENUM ('happy', 'neutral', 'sad'); ALTER TABLE users ADD COLUMN current_mood mood DEFAULT 'neutral'; -- Format numbers SELECT TO_CHAR(1234567.89, 'FM$999,999,999.00');
Result
Open