Excel快捷加表字段

Posted learn-not-to-have-already

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Excel快捷加表字段相关的知识,希望对你有一定的参考价值。

1. 添加表字段
=CONCAT("alter table ","表名"," add ",字段名," ",字段,";")       或者           =CONCAT("alter table ","表名"," add ",字段名," ",字段类型,"(",长度,",",精度,");")

2.给字段加注释

=CONCAT("comment on column ","表名",".",字段名," is ","‘",注释,"‘;")      ---pgsql

=CONCAT("EXEC sys.sp_addextendedproperty @name = N‘MS_Description‘,    @value = N‘",注释,"‘, @level0type = N‘SCHEMA‘,    @level0name = N‘dbo‘, @level1type = N‘TABLE‘,    @level1name = N‘","表名","‘, @level2type = N‘COLUMN‘,    @level2name = N‘",字段名,"‘;")                ---SQL server

可根据Excel 自由拼接。

3.查表序号,栏位名称,栏位长度,栏位说明     (注:表中无注释则不显示)

select row_number() over () 序号,
a.attname 栏位名称,
concat_ws(‘‘, t.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from ‘(.*)‘)) as 栏位长度,
d.description 栏位说明
from pg_class c,
pg_attribute a,
pg_type t,
pg_description d
where a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
and d.objoid = a.attrelid
and d.objsubid = a.attnum
and c.relname = ‘表名‘
order by c.relname, a.attnum;

以上是关于Excel快捷加表字段的主要内容,如果未能解决你的问题,请参考以下文章

执行 select ... for update 语句,如果查询条件没有索引字段的话,是加行锁还是加表锁?

请问在ArcGIS中如何提取原字段中的一部分?

请问在ArcGIS中如何提取原字段中的一部分?

求助!批量识别PDF中特定字段,并用该字段重新命名该PDF文件?

查询MySQL数据表的字段名和表结构

oracle字段怎么大写变小写,小写变大写