feat(hint): H2 Phase C batch 2 — DDL tier-3 hints (ADR-0053)
Per-form hints for the schema-shaping commands: create table, create m:n, add column/index/constraint, drop table/column/relationship/ index/constraint, rename column, change column (add_relationship was the Phase-B exemplar). Examples verified against the canonical usage templates. hint_ids wired on CREATE/CREATE_M2N/DROP/RENAME/CHANGE; catalogue + keys.rs registered. +2 spot tests (incl. multi-form DROP disambiguation); 2491 pass / 1 ignored, clippy clean.
This commit is contained in:
@@ -456,6 +456,55 @@ hint:
|
||||
copy:
|
||||
what: "Copy the output panel to the clipboard — all of it, or just the last command's output."
|
||||
example: "copy last"
|
||||
# DDL — schema-shaping commands (Phase C batch 2).
|
||||
create_table:
|
||||
what: "Create a new table — its columns, their types, and a primary key."
|
||||
example: "create table Customers with pk id(serial), name(text), email(text)"
|
||||
concept: "A table is a set of rows that share the same columns. The primary key uniquely identifies each row; a `serial` key numbers the rows for you."
|
||||
create_m2n:
|
||||
what: "Create a junction table linking two tables many-to-many."
|
||||
example: "create m:n relationship from Students to Courses"
|
||||
concept: "A many-to-many link (a student takes many courses; a course has many students) can't live in either table, so it gets its own junction table holding a foreign key to each side."
|
||||
add_column:
|
||||
what: "Add a new column to an existing table."
|
||||
example: "add column Customers: phone (text)"
|
||||
concept: "Existing rows take the column's default, or null. A `not null` column with no default can't be added to a table that already has rows — there'd be nothing to put in them."
|
||||
add_index:
|
||||
what: "Create an index on one or more columns to speed up lookups."
|
||||
example: "add index as idx_email on Customers (email)"
|
||||
concept: "An index is a sorted side-structure that makes a lookup like `where email = …` fast, at the cost of a little space and slightly slower writes."
|
||||
add_constraint:
|
||||
what: "Add a constraint — not null, unique, default, or check — to an existing column."
|
||||
example: "add constraint not null to Customers.email"
|
||||
concept: "A constraint is a rule the database enforces on every row. Adding one fails if existing rows already break it, so you fix the data first."
|
||||
drop_table:
|
||||
what: "Remove a table and all of its rows."
|
||||
example: "drop table Customers"
|
||||
concept: "If other tables reference this one through a relationship, drop those relationships (or their child rows) first — the database won't orphan them."
|
||||
drop_column:
|
||||
what: "Remove a column from a table."
|
||||
example: "drop column Customers: phone"
|
||||
concept: "The column's values are lost. You can't drop a primary-key column, or one a relationship depends on."
|
||||
drop_relationship:
|
||||
what: "Remove a relationship between two tables."
|
||||
example: "drop relationship customer_orders"
|
||||
concept: "This drops the foreign-key link and stops the database enforcing it; the tables and their rows stay. The foreign-key column itself remains unless you also drop it."
|
||||
drop_index:
|
||||
what: "Remove an index by name."
|
||||
example: "drop index idx_email"
|
||||
concept: "Only the lookup shortcut goes — the data is untouched. Queries still work, just without that speed-up."
|
||||
drop_constraint:
|
||||
what: "Remove a constraint from a column."
|
||||
example: "drop constraint not null from Customers.email"
|
||||
concept: "The rule stops being enforced from now on; rows already stored are left as they are."
|
||||
rename_column:
|
||||
what: "Rename a column, keeping its values and type."
|
||||
example: "rename column Customers: email to contact_email"
|
||||
concept: "Only the name changes — the stored data is the same. References to the column are reconciled so nothing breaks."
|
||||
change_column:
|
||||
what: "Change a column's type, converting the existing values."
|
||||
example: "change column Customers: status (int)"
|
||||
concept: "The database converts each stored value to the new type; if a value can't convert it refuses the change, so you don't silently lose data. Flags let you force or skip the conversion."
|
||||
err:
|
||||
foreign_key:
|
||||
child_side:
|
||||
|
||||
Reference in New Issue
Block a user