码迷,mamicode.com
首页 > 其他好文 > 详细

Excel快捷加表字段

时间:2019-12-06 13:56:31      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:number   end   evel   eve   sel   mat   substr   pgsql   位长   

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

标签:number   end   evel   eve   sel   mat   substr   pgsql   位长   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!