DB2 修改表


插入数值

db2 insert into <tab_name>(col1,col2,...) values(val1,val2,..)

实例:在”customer”表中插入值

db2 insert into professional.customer(custid, fullname, phone) values(100,'ravi','9898989')
db2 insert into professional.customer(custid, fullname, phone) values(101,'krathi','87996659')
db2 insert into professional.customer(custid, fullname, phone) values(102,'gopal','768678687')

改变列的类型

修改表结构时,使用”alter”命令

db2 alter table <tab_name> alter column <col_name> set data type <data_type>  

实例:员工表列”ID”的数据类型从”int”改为”bigint”

db2 alter table professional.employee alter column id set data type bigint      

变更列名

语法:修改表的列名从旧名称到新名称

db2 alter table <tab_name> rename column <old_name> to <new_name>     

实例:将”customers”表列名从”fullname”改为”custname”

db2 alter table professional.customer rename column fullname to custname       

评论区(0)

评论