SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE test(id BIGINT PRIMARY KEY, code TEXT, name TEXT, amount NUMERIC); ALTER TABLE test ADD CONSTRAINT uq_test_code UNIQUE (code); ALTER TABLE test ADD CONSTRAINT chk_test_name CHECK (name IS NOT NULL); ALTER TABLE test ADD CONSTRAINT chk_test_amount CHECK (amount >= 0 AND amount <= 1000000); SELECT n.nspname || '.' || c.relname table_name, cn.conname constraint_name, pg_catalog.pg_get_constraintdef(cn.oid, TRUE) constraint_description FROM pg_catalog.pg_constraint cn INNER JOIN pg_catalog.pg_class c ON c.oid = cn.conrelid INNER JOIN pg_catalog.pg_namespace n ON n.oid = cn.connamespace WHERE n.nspname = 'public' AND c.relname = 'test';

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear