I have file which contains n number of CREATE table query, I want to extract some particular tables create table query in unix. For Example in below file I just want extract create table query of table xyz.
CREATE TABLE ABC(
a INTEGER NOT NULL,
b INTEGER NOT NULL,
c CHAR(10) NOT NULL,
)
PARTITIONING KEY a USING HASHING
NOT LOGGED INITIALLY
;
ALTER TABLE abc
ADD PRIMARY KEY (a);
CREATE TABLE xyz(
a INTEGER NOT NULL,
b INTEGER NOT NULL,
c CHAR(10) NOT NULL,
)
PARTITIONING KEY a USING HASHING
NOT LOGGED INITIALLY
;
ALTER TABLE xyz
ADD PRIMARY KEY (a);
CREATE TABLE pqb(
a INTEGER NOT NULL,
b INTEGER NOT NULL,
c CHAR(10) NOT NULL,
)
PARTITIONING KEY a USING HASHING
NOT LOGGED INITIALLY
;
ALTER TABLE pqb
ADD PRIMARY KEY (a);
You could simply use
sed
to print the lines fromCREATE TABLE xyz
to;
:or with a parameter: