首页 > 其他 > 详细

Excel快捷加表字段

时间:2019-12-06 12:34:00      阅读:85      评论:0      收藏:0      [点我收藏+]

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快捷加表字段

原文:https://www.cnblogs.com/Learn-not-to-have-already/p/11994348.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!