You can modify database objects using ALTER. The database objects are related to data, so you must be careful enough to alter any objects. Why I am stressing is the mistake you made causes to lose all the data.
Given below are best SQL Queries on SQL ALTER. These are useful to use in your projects.
SQL ALTER statement
The objects on which ALTER you can use are TABLE, INDEX, FUNCTION, MASK, TABLESPACE, SERVER, SEQUENCE, and THRESHOLD
ALTER TABLE Add Column
ALTER TABLE table_name ADD COLUMN name_of_column;
In the above SQL query, you are adding new column name for an existing Table. Also, you can modify column data types.
ALTER INDEX index_name REGENERATE;
You cannot add new Index on existing Table. When you want to add new index, you need to drop existing ones and to create new ones.
The REGENERATE specifies that the index will be regenerated or rebuild. This command is useful if an index already created.
ALTER DATABASE database_name new_buffer_pool;
You can modify database parameters. This is to add more buffer-pools. Also, you can add storage or drop storage.
ALTER FUNCTION GET_TABLE RESTRICT CARDINALITY 10000;
In the above SQL, you can modify the parameters given in the user defined functions.
The Bottom Line
The ALTER statement in production region only Admins will handle. In test regions, all the developers have access to do their research.
- Golang top handy Interview Questions
- 3 SQL tuning ideas on Table Columns to apply
- Top Components behind the scenes in Hyperledger Fabric
- DB2 derived Table key knowledge Points you need to learn
- 9 Linux tricky Points Every User must know