Excel quickly add table fields

1. Add Field
= CONCAT ( "alter table", " table ", "the Add" field name , "", field type , ";") or = CONCAT ( "alter table", " table ", " the Add " field name ," " field type " ( "length", "accuracy"); ")

2. to add a comment field

=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

Can be spliced ​​according to Excel free.

3. The look-up table number, field name, field length, the field description (Note: No comment is not displayed in the table)

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;

Guess you like

Origin www.cnblogs.com/Learn-not-to-have-already/p/11994348.html