CREATE SCHEMA salesforce;

--DROP TABLE salesforce.account;
CREATE TABLE IF NOT EXISTS salesforce.account
(
id VARCHAR(16383) ENCODE lzo
,isdeleted BOOLEAN ENCODE RAW
,masterrecordid VARCHAR(16383) ENCODE lzo
,name VARCHAR(16383) ENCODE lzo
,"type" VARCHAR(16383) ENCODE lzo
,parentid VARCHAR(16383) ENCODE lzo
,billingstreet VARCHAR(16383) ENCODE lzo
,billingcity VARCHAR(16383) ENCODE lzo
,billingstate VARCHAR(16383) ENCODE lzo
,billingpostalcode VARCHAR(16383) ENCODE lzo
,billingcountry VARCHAR(16383) ENCODE lzo
,billinglatitude VARCHAR(16383) ENCODE lzo
,billinglongitude VARCHAR(16383) ENCODE lzo
,billinggeocodeaccuracy VARCHAR(16383) ENCODE lzo
,shippingstreet VARCHAR(16383) ENCODE lzo
,shippingcity VARCHAR(16383) ENCODE lzo
,shippingstate VARCHAR(16383) ENCODE lzo
,shippingpostalcode VARCHAR(16383) ENCODE lzo
,shippingcountry VARCHAR(16383) ENCODE lzo
,shippinglatitude VARCHAR(16383) ENCODE lzo
,shippinglongitude VARCHAR(16383) ENCODE lzo
,shippinggeocodeaccuracy VARCHAR(16383) ENCODE lzo
,phone VARCHAR(16383) ENCODE lzo
,fax VARCHAR(16383) ENCODE lzo
,website VARCHAR(16383) ENCODE lzo
,photourl VARCHAR(16383) ENCODE lzo
,industry VARCHAR(16383) ENCODE lzo
,annualrevenue DOUBLE PRECISION ENCODE RAW
,numberofemployees INTEGER ENCODE az64
,description VARCHAR(16383) ENCODE lzo
,ownerid VARCHAR(16383) ENCODE lzo
,createddate VARCHAR(16383) ENCODE lzo
,createdbyid VARCHAR(16383) ENCODE lzo
,lastmodifieddate VARCHAR(16383) ENCODE lzo
,lastmodifiedbyid VARCHAR(16383) ENCODE lzo
,systemmodstamp VARCHAR(16383) ENCODE lzo
,lastactivitydate VARCHAR(16383) ENCODE lzo
,lastvieweddate VARCHAR(16383) ENCODE lzo
,lastreferenceddate VARCHAR(16383) ENCODE lzo
,jigsaw VARCHAR(16383) ENCODE lzo
,jigsawcompanyid VARCHAR(16383) ENCODE lzo
,accountsource VARCHAR(16383) ENCODE lzo
,sicdesc VARCHAR(16383) ENCODE lzo
,partition_0 VARCHAR(16383) ENCODE lzo
)
DISTSTYLE EVEN
;

--DROP TABLE salesforce."case";
CREATE TABLE IF NOT EXISTS salesforce."case"
(
id VARCHAR(16383) ENCODE lzo
,isdeleted BOOLEAN ENCODE RAW
,masterrecordid VARCHAR(16383) ENCODE lzo
,casenumber VARCHAR(16383) ENCODE lzo
,contactid VARCHAR(16383) ENCODE lzo
,accountid VARCHAR(16383) ENCODE lzo
,parentid VARCHAR(16383) ENCODE lzo
,suppliedname VARCHAR(16383) ENCODE lzo
,suppliedemail VARCHAR(16383) ENCODE lzo
,suppliedphone VARCHAR(16383) ENCODE lzo
,suppliedcompany VARCHAR(16383) ENCODE lzo
,"type" VARCHAR(16383) ENCODE lzo
,status VARCHAR(16383) ENCODE lzo
,reason VARCHAR(16383) ENCODE lzo
,origin VARCHAR(16383) ENCODE lzo
,subject VARCHAR(16383) ENCODE lzo
,priority VARCHAR(16383) ENCODE lzo
,description VARCHAR(16383) ENCODE lzo
,isclosed BOOLEAN ENCODE RAW
,closeddate VARCHAR(16383) ENCODE lzo
,isescalated BOOLEAN ENCODE RAW
,ownerid VARCHAR(16383) ENCODE lzo
,createddate VARCHAR(16383) ENCODE lzo
,createdbyid VARCHAR(16383) ENCODE lzo
,lastmodifieddate VARCHAR(16383) ENCODE lzo
,lastmodifiedbyid VARCHAR(16383) ENCODE lzo
,systemmodstamp VARCHAR(16383) ENCODE lzo
,contactphone VARCHAR(16383) ENCODE lzo
,contactmobile VARCHAR(16383) ENCODE lzo
,contactemail VARCHAR(16383) ENCODE lzo
,contactfax VARCHAR(16383) ENCODE lzo
,comments VARCHAR(16383) ENCODE lzo
,lastvieweddate VARCHAR(16383) ENCODE lzo
,lastreferenceddate VARCHAR(16383) ENCODE lzo
,partition_0 VARCHAR(16383) ENCODE lzo
)
DISTSTYLE EVEN
;

--DROP TABLE salesforce.contact;
CREATE TABLE IF NOT EXISTS salesforce.contact
(
id VARCHAR(16383) ENCODE lzo
,isdeleted BOOLEAN ENCODE RAW
,masterrecordid VARCHAR(16383) ENCODE lzo
,accountid VARCHAR(16383) ENCODE lzo
,lastname VARCHAR(16383) ENCODE lzo
,firstname VARCHAR(16383) ENCODE lzo
,salutation VARCHAR(16383) ENCODE lzo
,name VARCHAR(16383) ENCODE lzo
,otherstreet VARCHAR(16383) ENCODE lzo
,othercity VARCHAR(16383) ENCODE lzo
,otherstate VARCHAR(16383) ENCODE lzo
,otherpostalcode VARCHAR(16383) ENCODE lzo
,othercountry VARCHAR(16383) ENCODE lzo
,otherlatitude VARCHAR(16383) ENCODE lzo
,otherlongitude VARCHAR(16383) ENCODE lzo
,othergeocodeaccuracy VARCHAR(16383) ENCODE lzo
,mailingstreet VARCHAR(16383) ENCODE lzo
,mailingcity VARCHAR(16383) ENCODE lzo
,mailingstate VARCHAR(16383) ENCODE lzo
,mailingpostalcode VARCHAR(16383) ENCODE lzo
,mailingcountry VARCHAR(16383) ENCODE lzo
,mailinglatitude VARCHAR(16383) ENCODE lzo
,mailinglongitude VARCHAR(16383) ENCODE lzo
,mailinggeocodeaccuracy VARCHAR(16383) ENCODE lzo
,phone VARCHAR(16383) ENCODE lzo
,fax VARCHAR(16383) ENCODE lzo
,mobilephone VARCHAR(16383) ENCODE lzo
,homephone VARCHAR(16383) ENCODE lzo
,otherphone VARCHAR(16383) ENCODE lzo
,assistantphone VARCHAR(16383) ENCODE lzo
,reportstoid VARCHAR(16383) ENCODE lzo
,email VARCHAR(16383) ENCODE lzo
,title VARCHAR(16383) ENCODE lzo
,department VARCHAR(16383) ENCODE lzo
,assistantname VARCHAR(16383) ENCODE lzo
,leadsource VARCHAR(16383) ENCODE lzo
,birthdate VARCHAR(16383) ENCODE lzo
,description VARCHAR(16383) ENCODE lzo
,ownerid VARCHAR(16383) ENCODE lzo
,createddate VARCHAR(16383) ENCODE lzo
,createdbyid VARCHAR(16383) ENCODE lzo
,lastmodifieddate VARCHAR(16383) ENCODE lzo
,lastmodifiedbyid VARCHAR(16383) ENCODE lzo
,systemmodstamp VARCHAR(16383) ENCODE lzo
,lastactivitydate VARCHAR(16383) ENCODE lzo
,lastcurequestdate VARCHAR(16383) ENCODE lzo
,lastcuupdatedate VARCHAR(16383) ENCODE lzo
,lastvieweddate VARCHAR(16383) ENCODE lzo
,lastreferenceddate VARCHAR(16383) ENCODE lzo
,emailbouncedreason VARCHAR(16383) ENCODE lzo
,emailbounceddate VARCHAR(16383) ENCODE lzo
,isemailbounced BOOLEAN ENCODE RAW
,photourl VARCHAR(16383) ENCODE lzo
,jigsaw VARCHAR(16383) ENCODE lzo
,jigsawcontactid VARCHAR(16383) ENCODE lzo
,individualid VARCHAR(16383) ENCODE lzo
,partition_0 VARCHAR(16383) ENCODE lzo
)
DISTSTYLE EVEN
;

--DROP TABLE salesforce.oppurtunity;
CREATE TABLE IF NOT EXISTS salesforce.oppurtunity
(
id VARCHAR(16383) ENCODE lzo
,isdeleted BOOLEAN ENCODE RAW
,accountid VARCHAR(16383) ENCODE lzo
,name VARCHAR(16383) ENCODE lzo
,description VARCHAR(16383) ENCODE lzo
,stagename VARCHAR(16383) ENCODE lzo
,amount DOUBLE PRECISION ENCODE RAW
,probability DOUBLE PRECISION ENCODE RAW
,closedate VARCHAR(16383) ENCODE lzo
,"type" VARCHAR(16383) ENCODE lzo
,nextstep VARCHAR(16383) ENCODE lzo
,leadsource VARCHAR(16383) ENCODE lzo
,isclosed BOOLEAN ENCODE RAW
,iswon BOOLEAN ENCODE RAW
,forecastcategory VARCHAR(16383) ENCODE lzo
,forecastcategoryname VARCHAR(16383) ENCODE lzo
,hasopportunitylineitem BOOLEAN ENCODE RAW
,pricebook2id VARCHAR(16383) ENCODE lzo
,ownerid VARCHAR(16383) ENCODE lzo
,createddate VARCHAR(16383) ENCODE lzo
,createdbyid VARCHAR(16383) ENCODE lzo
,lastmodifieddate VARCHAR(16383) ENCODE lzo
,lastmodifiedbyid VARCHAR(16383) ENCODE lzo
,systemmodstamp VARCHAR(16383) ENCODE lzo
,lastactivitydate VARCHAR(16383) ENCODE lzo
,fiscalquarter INTEGER ENCODE az64
,fiscalyear INTEGER ENCODE az64
,fiscal VARCHAR(16383) ENCODE lzo
,contactid VARCHAR(16383) ENCODE lzo
,lastvieweddate VARCHAR(16383) ENCODE lzo
,lastreferenceddate VARCHAR(16383) ENCODE lzo
,hasopenactivity BOOLEAN ENCODE RAW
,hasoverduetask BOOLEAN ENCODE RAW
,partition_0 VARCHAR(16383) ENCODE lzo
)
DISTSTYLE EVEN
;

--DROP TABLE salesforce."user";
CREATE TABLE IF NOT EXISTS salesforce."user"
(
id VARCHAR(16383) ENCODE lzo
,username VARCHAR(16383) ENCODE lzo
,lastname VARCHAR(16383) ENCODE lzo
,firstname VARCHAR(16383) ENCODE lzo
,name VARCHAR(16383) ENCODE lzo
,companyname VARCHAR(16383) ENCODE lzo
,division VARCHAR(16383) ENCODE lzo
,department VARCHAR(16383) ENCODE lzo
,title VARCHAR(16383) ENCODE lzo
,street VARCHAR(16383) ENCODE lzo
,city VARCHAR(16383) ENCODE lzo
,state VARCHAR(16383) ENCODE lzo
,postalcode VARCHAR(16383) ENCODE lzo
,country VARCHAR(16383) ENCODE lzo
,latitude VARCHAR(16383) ENCODE lzo
,longitude VARCHAR(16383) ENCODE lzo
,geocodeaccuracy VARCHAR(16383) ENCODE lzo
,email VARCHAR(16383) ENCODE lzo
,emailpreferencesautobcc BOOLEAN ENCODE RAW
,emailpreferencesautobccstayintouch BOOLEAN ENCODE RAW
,emailpreferencesstayintouchreminder BOOLEAN ENCODE RAW
,senderemail VARCHAR(16383) ENCODE lzo
,sendername VARCHAR(16383) ENCODE lzo
,signature VARCHAR(16383) ENCODE lzo
,stayintouchsubject VARCHAR(16383) ENCODE lzo
,stayintouchsignature VARCHAR(16383) ENCODE lzo
,stayintouchnote VARCHAR(16383) ENCODE lzo
,phone VARCHAR(16383) ENCODE lzo
,fax VARCHAR(16383) ENCODE lzo
,mobilephone VARCHAR(16383) ENCODE lzo
,alias VARCHAR(16383) ENCODE lzo
,communitynickname VARCHAR(16383) ENCODE lzo
,badgetext VARCHAR(16383) ENCODE lzo
,isactive BOOLEAN ENCODE RAW
,timezonesidkey VARCHAR(16383) ENCODE lzo
,userroleid VARCHAR(16383) ENCODE lzo
,localesidkey VARCHAR(16383) ENCODE lzo
,receivesinfoemails BOOLEAN ENCODE RAW
,receivesadmininfoemails BOOLEAN ENCODE RAW
,emailencodingkey VARCHAR(16383) ENCODE lzo
,profileid VARCHAR(16383) ENCODE lzo
,usertype VARCHAR(16383) ENCODE lzo
,languagelocalekey VARCHAR(16383) ENCODE lzo
,employeenumber VARCHAR(16383) ENCODE lzo
,delegatedapproverid VARCHAR(16383) ENCODE lzo
,managerid VARCHAR(16383) ENCODE lzo
,lastlogindate VARCHAR(16383) ENCODE lzo
,lastpasswordchangedate VARCHAR(16383) ENCODE lzo
,createddate VARCHAR(16383) ENCODE lzo
,createdbyid VARCHAR(16383) ENCODE lzo
,lastmodifieddate VARCHAR(16383) ENCODE lzo
,lastmodifiedbyid VARCHAR(16383) ENCODE lzo
,systemmodstamp VARCHAR(16383) ENCODE lzo
,numberoffailedlogins INTEGER ENCODE az64
,offlinetrialexpirationdate VARCHAR(16383) ENCODE lzo
,offlinepdatrialexpirationdate VARCHAR(16383) ENCODE lzo
,userpermissionsmarketinguser BOOLEAN ENCODE RAW
,userpermissionsofflineuser BOOLEAN ENCODE RAW
,userpermissionsavantgouser BOOLEAN ENCODE RAW
,userpermissionscallcenterautologin BOOLEAN ENCODE RAW
,userpermissionsmobileuser BOOLEAN ENCODE RAW
,userpermissionssfcontentuser BOOLEAN ENCODE RAW
,userpermissionsinteractionuser BOOLEAN ENCODE RAW
,forecastenabled BOOLEAN ENCODE RAW
,userpreferencesactivityreminderspopup BOOLEAN ENCODE RAW
,userpreferenceseventreminderscheckboxdefault BOOLEAN ENCODE RAW
,userpreferencestaskreminderscheckboxdefault BOOLEAN ENCODE RAW
,userpreferencesremindersoundoff BOOLEAN ENCODE RAW
,userpreferencesdisableallfeedsemail BOOLEAN ENCODE RAW
,userpreferencesdisablefollowersemail BOOLEAN ENCODE RAW
,userpreferencesdisableprofilepostemail BOOLEAN ENCODE RAW
,userpreferencesdisablechangecommentemail BOOLEAN ENCODE RAW
,userpreferencesdisablelatercommentemail BOOLEAN ENCODE RAW
,userpreferencesdisprofpostcommentemail BOOLEAN ENCODE RAW
,userpreferencescontentnoemail BOOLEAN ENCODE RAW
,userpreferencescontentemailasandwhen BOOLEAN ENCODE RAW
,userpreferencesapexpagesdevelopermode BOOLEAN ENCODE RAW
,userpreferencesreceivenonotificationsasapprover BOOLEAN ENCODE RAW
,userpreferencesreceivenotificationsasdelegatedapprover BOOLEAN ENCODE RAW
,userpreferenceshidecsngetchattermobiletask BOOLEAN ENCODE RAW
,userpreferencesdisablementionspostemail BOOLEAN ENCODE RAW
,userpreferencesdismentionscommentemail BOOLEAN ENCODE RAW
,userpreferenceshidecsndesktoptask BOOLEAN ENCODE RAW
,userpreferenceshidechatteronboardingsplash BOOLEAN ENCODE RAW
,userpreferenceshidesecondchatteronboardingsplash BOOLEAN ENCODE RAW
,userpreferencesdiscommentafterlikeemail BOOLEAN ENCODE RAW
,userpreferencesdisablelikeemail BOOLEAN ENCODE RAW
,userpreferencessortfeedbycomment BOOLEAN ENCODE RAW
,userpreferencesdisablemessageemail BOOLEAN ENCODE RAW
,userpreferencesdisablebookmarkemail BOOLEAN ENCODE RAW
,userpreferencesdisablesharepostemail BOOLEAN ENCODE RAW
,userpreferencesenableautosubforfeeds BOOLEAN ENCODE RAW
,userpreferencesdisablefilesharenotificationsforapi BOOLEAN ENCODE RAW
,userpreferencesshowtitletoexternalusers BOOLEAN ENCODE RAW
,userpreferencesshowmanagertoexternalusers BOOLEAN ENCODE RAW
,userpreferencesshowemailtoexternalusers BOOLEAN ENCODE RAW
,userpreferencesshowworkphonetoexternalusers BOOLEAN ENCODE RAW
,userpreferencesshowmobilephonetoexternalusers BOOLEAN ENCODE RAW
,userpreferencesshowfaxtoexternalusers BOOLEAN ENCODE RAW
);

select id
,type
,industry
,annualrevenue
,createddate
,phone
,billingstreet
,shippingstreet
 from salesforce.account;

