Junior — Middle
Tell about your experience of modifying database structures using DDL commands.
sobes.tech AI
Answer from AI
In my practice, I have used DDL (Data Definition Language) commands to modify the database structure, such as:
CREATE TABLE— creating new tables.ALTER TABLE— modifying the structure of existing tables (adding/removing columns, changing data types).DROP TABLE— deleting tables.
For example, to add a new column to the users table:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
Or to change the data type of a column:
ALTER TABLE orders ALTER COLUMN amount TYPE DECIMAL(10,2);
In projects, I also used migrations (for example, with Liquibase or Flyway) to manage database schema changes consistently and in a team, which allows rolling back changes and tracking modification history.