multi line match regular expression

From: Sundaram Ramasamy (sun@percipia.com)
Date: Tue Jun 10 2003 - 02:23:15 EDT


Hi,

I have the following SQL statements in a text file. I want to extract all
insert SQL statements fist, then I want to extract all create SQL statement.

Can some one help me with sed or perl regular expression for this?

Thanks
-SR

CREATE TABLE if not exists ptable (
    id VARCHAR(60),
    name varchar(100),
    PRIMARY KEY ( id ),
    UNIQUE INDEX premiseidx ( id ) );
insert into ptable (id)
values( '660233992481342shujmbodgVNY34811731p4CE10IIMp06CKOWags',
'Columbus');
CREATE TABLE if not exists userinfotable (
        userid VARCHAR(20) PRIMARY KEY,
        password VARCHAR(20) NOT NULL,
        lname VARCHAR(30) NOT NULL DEFAULT "",
        fname VARCHAR(30) NOT NULL DEFAULT "",
        priv INT(5) NOT NULL DEFAULT 0
        );
INSERT INTO userinfotable VALUES ('aa', 'c3lzMTIz', 'aa', 'sys', 3);
INSERT INTO userinfotable VALUES ('ddd', 'ZGVtbw==', 'ddd', 'demo', 3);
CREATE TABLE if not exists roomhistorytable(
    id INTEGER DEFAULT 1 auto_increment,
    roomno VARCHAR( 5 ) NOT NULL,
    transtype INTEGER NOT NULL,
    transtime DATETIME NOT NULL,
    transsource INTEGER,
    transsubsource VARCHAR(25),
    transparams VARCHAR(225),
    transresult INTEGER,
    transresultdetails VARCHAR(225),
    PRIMARY KEY (id),
    INDEX roomhistoryidx(id) );
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:26:34 EDT