AI Skill Report Card

Adding Database Columns

B-72·Feb 12, 2026·Source: Web
15 / 15
SQL
ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name data_type;
Recommendation
Add database-specific syntax variations with complete examples for PostgreSQL, MySQL, and SQLite
12 / 15
  1. Identify target table and column requirements

    • Table name
    • Column name
    • Data type
    • Constraints (if any)
  2. Check if column exists (optional but recommended)

    SQL
    SELECT column_name FROM information_schema.columns WHERE table_name = 'your_table' AND column_name = 'your_column';
  3. Execute ALTER TABLE statement

    SQL
    ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name data_type;
  4. Verify addition

    SQL
    \d table_name -- PostgreSQL DESCRIBE table_name; -- MySQL
Recommendation
Include rollback/undo procedures (DROP COLUMN statements) for completeness
18 / 20

Example 1: Input: Add a JSONB column for storing scores Output:

SQL
ALTER TABLE skills ADD COLUMN IF NOT EXISTS criterion_scores jsonb;

Example 2: Input: Add nullable text column with default Output:

SQL
ALTER TABLE users ADD COLUMN IF NOT EXISTS bio text DEFAULT '';

Example 3: Input: Add non-null integer with constraint Output:

SQL
ALTER TABLE products ADD COLUMN IF NOT EXISTS priority integer NOT NULL DEFAULT 1 CHECK (priority >= 1 AND priority <= 5);
Recommendation
Provide templates for common column patterns (timestamps, foreign keys, indexes) rather than just basic ALTER statements
  • Always use IF NOT EXISTS to prevent errors on re-runs
  • Choose appropriate data types (jsonb for JSON, text for strings, timestamp for dates)
  • Consider adding defaults for non-null columns
  • Use meaningful column names that follow your naming convention
  • Test on development environment first
  • Forgetting IF NOT EXISTS clause causing errors on duplicate runs
  • Adding non-null columns without defaults to tables with existing data
  • Using reserved keywords as column names without proper quoting
  • Mixing up database-specific syntax (MySQL vs PostgreSQL vs SQLite)
0
Grade B-AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
12/15
Examples
18/20
Completeness
0/20
Format
15/15
Conciseness
12/15