Here are the five uses of SQL ALTER. You can add columns, add indexes, add keys, add buffer pools, and modify function parameters. Here are the best SQL Queries on SQL ALTER. These are useful to use in your projects.
SQL ALTER Can be Used to These Five
SQL ALTER statement
The objects on which ALTER you can use are TABLE, INDEX, FUNCTION, MASK, TABLESPACE, SERVER, SEQUENCE, and THRESHOLD
1. ALTER TABLE Add Column
In the above SQL query, you are adding new column name for an existing Table. Also, you can modify column data types.
ALTER TABLE table_name ADD COLUMN name_of_column;
2. ALTER INDEX
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 INDEX index_name REGENERATE;
3. ALTER DATABASE
You can modify database parameters. This is to add more buffer-pools. Also, you can add storage or drop storage.
ALTER DATABASE database_name new_buffer_pool;
5. ALTER FUNCTION
In the above SQL, you can modify the parameters given in the user defined functions.
ALTER FUNCTION GET_TABLE
RESTRICT CARDINALITY 10000;
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.