- 论坛徽章:
- 0
|
20可用积分
本帖最后由 wangdonsy 于 2019-11-15 22:00 编辑
帮忙看一下这种怎么shell处理
1. 匹配建表语句中的“”,把引号里面的内容改为大写
create table test1 (
"mode" varchar(100),
id int;
address varchar(100)
);
alter table test1 owner "testuser";
create table test2 (
"name" varchar(100),
id int;
address varchar(100)
);
alter table test2 owner "testuser";
先匹配() ,再匹配有双引号的字段名,匹配后把字段名转为大写
生成的结果如下:
create table test1 (
"MODE" varchar(100),
id int;
address varchar(100)
);
alter table test1 owner "testuser";
create table test2 (
"NAME" varchar(100),
id int;
address varchar(100)
);
alter table test2 owner "testuser";
2 匹配建表语句中的关键字,把关键字变为大写加双引号,如关键字列表有:mode,name
create table test1 (
mode varchar(100),
id int;
address varchar(100)
);
alter table test1 owner "testuser";
create table test2 (
name varchar(100),
id int;
address varchar(100)
);
alter table test2 owner "testuser";
匹配后最终的结果为
create table test1 (
"MODE" varchar(100),
id int;
address varchar(100)
);
alter table test1 owner "testuser";
create table test2 (
"NAME" varchar(100),
id int;
address varchar(100)
);
alter table test2 owner "testuser";
|
|