在数据库表中,查询新列的sql示例如下,
1、创建测试表,createtabletest_num(idnumber,feenumber(10,3))
2、查看表的属性,共包含两列,ID、FEE,
3、执行sql语句,插入新字段,altertabletest_numadd(fee2number(10,3))
4、重新查看表结构,字段已加上,
一、SQL中新增列或者说添加字段的语法:
alter table 表名 add 列名 数据类型
二、例如:在表texttable中添加一列字符型字段colnew:
alter table texttable add colnew char(20)三、添加的新列,默认值为空值NULL。需要根据需求使用SQL语句更改
1、SQL修改列的语法:
update 表名 set 字段 = 赋值 where字句(确定要修改的列)
2、实例:
update texttable set colnew = 'temp'--把所有行的 colnew列的值改为 "temp"update texttable set colnew = 'temp' where id=1000 --把ID为1000的行 colnew列的值改为 "temp"
一、SQL中新增列或者说添加字段的语法: alter table 表名 add 列名 数据类型 二、例如:在表texttable中添加一列字符型字段colnew: alter table texttable add colnew char(20)三、添加的新列,默认值为空值NULL欢迎分享,转载请注明来源:内存溢出
评论列表(0条)