Loading...
Loading...
Master PostgreSQL SQL fundamentals - data types, tables, constraints, schema design
npx skill4agent add pluginagentmarketplace/custom-plugin-postgresql postgresql-fundamentalsAtomic skill for SQL foundations and schema design
parameters:
operation:
type: string
required: true
enum: [create_table, add_constraint, select_type, design_schema]
table_name:
type: string
pattern: "^[a-z][a-z0-9_]*$"
schema:
type: string
default: "public"| Use Case | Recommended | Avoid |
|---|---|---|
| Primary key | | |
| Monetary | | |
| Timestamps | | |
| UUID | | |
| JSON data | | |
CREATE TABLE schema_name.table_name (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);-- Foreign key
CONSTRAINT fk_name FOREIGN KEY (col) REFERENCES other(id) ON DELETE CASCADE;
-- Check
CONSTRAINT chk_positive CHECK (amount > 0);
-- Unique
CONSTRAINT uq_email UNIQUE (email);| Rule | Pattern |
|---|---|
| Table names | |
| Column names | |
DO $$ BEGIN
DROP TABLE IF EXISTS test_users;
CREATE TABLE test_users (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY);
ASSERT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'test_users');
DROP TABLE test_users;
END $$;| Error | Cause | Solution |
|---|---|---|
| Table exists | Use IF NOT EXISTS |
| Duplicate key | Check constraints |
| Column not found | Verify names |
Skill("postgresql-fundamentals")