- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the length of the Name column from CHAR(20) to CHAR(50)?
DB2 gives us an option of modifying the attribute of the existing column in a table. We have to use the ALTER COLUMN parameter with ALTER TABLE as below in order to achieve this.
ALTER TABLE DBSET1.TAB1 ALTER COLUMN NAME SET DATATYPE CHAR(50);
The ALTER TABLE reserved words are followed by the name of the table qualified by a database, which is DBSET1.TAB1 in this case. Similarly, ALTER COLUMN is followed by the name of the column which needs to be modified, which NAME (of the student) in this case.
In the SET DATATYPE parameter, we can pass the new length 50 for the NAME column.
Advertisements