<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: create table from database schema in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494961#M137977</link>
    <description>&lt;P&gt;I give up.  My answer gives you all of the building blocks that you need to make a working solution.  There is something about your sample data that is different from your real data.&lt;/P&gt;</description>
    <pubDate>Sat, 30 Nov 2019 04:20:45 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-11-30T04:20:45Z</dc:date>
    <item>
      <title>create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494950#M137966</link>
      <description>&lt;P&gt;hi &lt;BR /&gt;
i have database schema, and want to extract a table like in picture.&lt;BR /&gt;
i try to use regular expression but it's not work, explain here; &lt;A href="https://answers.splunk.com/answers/786057/field-extract-1.html"&gt;https://answers.splunk.com/answers/786057/field-extract-1.html&lt;/A&gt;&lt;BR /&gt;
and field extraction of splunk is so limited because could not accept multi value and special character!&lt;/P&gt;

&lt;P&gt;any recommendation ?&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8018iF05CC44E6683FB54/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;primary key (code)  constraint "informix".pk_code

create index "informix".account_index on "informix".account
    (pu_date) using ct  in indexdbs;/create 

create unique index "informix".account_uidx on "informix".account
    (uno,sub_no) using ct in indexdbs;

create trigger "informix".accounttrigger insert on "informix"

alter table "informix".account add constraint (foreign key
    (account_fk) references "informix".etc
     constraint "informix".acc_type);



create table "informix".customer

primary key (id)  constraint "informix".pk.id

create index "informix".customer_index on "informix".customer
    (pu_date) using ct  in indexdbs;/create 

create unique index "informix".customer_uidx on "informix".customer
    (uno,sub_no) using ct in indexdbs;

create trigger "informix".customertrigger insert on "informix"

alter table "informix".customer add constraint (foreign key
    (customer_fk) references "informix".etc
     constraint "informix".acc_type);


create table "informix".merchant 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Nov 2019 19:04:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494950#M137966</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-28T19:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494951#M137967</link>
      <description>&lt;P&gt;Why did you give up on the other question? I posted an answer 2 days ago that works fine.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 03:32:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494951#M137967</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T03:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494952#M137968</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
|  eval _raw="create table \"informix\".account

primary key (code)  constraint \"informix\".pk_code

create index \"informix\".account_index on \"informix\".account
    (pu_date) using ct  in indexdbs;/create 

create unique index \"informix\".account_uidx on \"informix\".account
    (uno,sub_no) using ct in indexdbs;

create trigger \"informix\".accounttrigger insert on \"informix\"

alter table \"informix\".account add constraint (foreign key
    (account_fk) references \"informix\".etc
     constraint \"informix\".acc_type);



create table \"informix\".customer

primary key (id)  constraint \"informix\".pk.id

create index \"informix\".customer_index on \"informix\".customer
    (pu_date) using ct  in indexdbs;/create 

create unique index \"informix\".customer_uidx on \"informix\".customer
    (uno,sub_no) using ct in indexdbs;

create trigger \"informix\".customertrigger insert on \"informix\"

alter table \"informix\".customer add constraint (foreign key
    (customer_fk) references \"informix\".etc
     constraint \"informix\".acc_type);


create table \"informix\".merchant"

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution."

| eval raw = split(_raw, "create table")
| fields raw
| fields - _*
| mvexpand raw
| rex field=raw mode=sed "s/^/create table/"
| rex field=raw max_match=0 "create (?&amp;lt;object&amp;gt;\S+)[^\.]+\.(?&amp;lt;value&amp;gt;\S+)"
| rex field=raw max_match=0 "\(foreign key[\r\n\s]+\((?&amp;lt;foreign_key&amp;gt;[^\)]+)"
| eval raw = mvzip(object, value, "=")
| rename raw AS _raw
| kv
| where isnotnull(table)
| table table index trigger foreign_key
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2019 04:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494952#M137968</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T04:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494953#M137969</link>
      <description>&lt;P&gt;Not give up, Giuseppe told this is new question, I try to create more clear question &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 04:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494953#M137969</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-29T04:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494954#M137970</link>
      <description>&lt;P&gt;Error in 'makeresults' command: This command must be the first command of a search. &lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 05:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494954#M137970</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-29T05:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494955#M137971</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8017i597248485CA558A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 06:37:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494955#M137971</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-29T06:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494956#M137972</link>
      <description>&lt;P&gt;&lt;CODE&gt;kv&lt;/CODE&gt; is so cool.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 11:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494956#M137972</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-29T11:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494957#M137973</link>
      <description>&lt;P&gt;Read what I wrote on line #39.  Your solution starts on line #41.  As far as the error, if you are testing everything, you missed the leading pipe ( &lt;CODE&gt;|&lt;/CODE&gt; ).&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 17:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494957#M137973</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T17:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494958#M137974</link>
      <description>&lt;P&gt;Yes, indeed.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 17:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494958#M137974</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T17:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494959#M137975</link>
      <description>&lt;P&gt;Sorry it was my fault , after i wrote comment see that part, but after check that part it only fill table name, other columns were empty!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 18:56:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494959#M137975</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-29T18:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494960#M137976</link>
      <description>&lt;P&gt;Then there is something different about your events than the data that you posted.  Take my full answer with fake events data, break it apart, learn how it does what it does, then adjust it to fit your real data.  The core concepts and functional components are all there to do what you need.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 19:50:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494960#M137976</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T19:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494961#M137977</link>
      <description>&lt;P&gt;I give up.  My answer gives you all of the building blocks that you need to make a working solution.  There is something about your sample data that is different from your real data.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 04:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494961#M137977</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-30T04:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494962#M137978</link>
      <description>&lt;P&gt;First of all thank you so much for that time you spend on this issue,&lt;BR /&gt;
Second I Just copy and past here portion of real db schema. And I got confused why only first column appear! And why first row is 0! there is no table with that name!&lt;/P&gt;

&lt;P&gt;While I can grep in bash “index”, “trigger”, “create table”, and other fields without problem.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 17:48:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494962#M137978</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-30T17:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494963#M137979</link>
      <description>&lt;P&gt;I am only giving up because there is nowhere else for us to go.  My solution works for the data you posted but if it doesn't work in your environment, I would actually have to see it on your Search Head and you probably aren't ready to hire me to come in for that.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 17:58:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494963#M137979</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-30T17:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494964#M137980</link>
      <description>&lt;P&gt;You right, Thank you again for your answer. I should review your solution again and splunk documents to find out why it’s not work correctly when I run.&lt;BR /&gt;
Regard, &lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 18:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494964#M137980</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-11-30T18:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494965#M137981</link>
      <description>&lt;P&gt;It is better to check the results by executing one line at a time.&lt;BR /&gt;
You need to check if the field is extracted as a result of &lt;CODE&gt;rex&lt;/CODE&gt;.&lt;BR /&gt;
Good luck.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 23:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494965#M137981</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-30T23:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494966#M137982</link>
      <description>&lt;P&gt;It work separately but when I add another one mess up.&lt;BR /&gt;
And I think “index” is a reserved keyword in splunk, when change index column name it will appear. &lt;/P&gt;</description>
      <pubDate>Sun, 01 Dec 2019 15:27:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494966#M137982</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-01T15:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: create table from database schema</title>
      <link>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494967#M137983</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="source=test, index=abc"
| extract
| append 
    [| makeresults 
    | eval _raw="abd, test"
    | rex "(?&amp;lt;index&amp;gt;\w+), (?&amp;lt;source&amp;gt;\w+)"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is not the case.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Dec 2019 16:56:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/create-table-from-database-schema/m-p/494967#M137983</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-01T16:56:27Z</dc:date>
    </item>
  </channel>
</rss>

