{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Salesforce Marketing Cloud V2 Export Integration Using CLI","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"salesforce-marketing-cloud-v2-export-integration-using-cli","__idx":0},"children":["Salesforce Marketing Cloud V2 Export Integration Using CLI"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure CLIを使用してクエリを実行し、出力結果をSalesforce Marketing Cloudに書き込むことができます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"treasure-cliでクエリを実行する","__idx":1},"children":["Treasure CLIでクエリを実行する"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Asynchronous API"]},"と",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Legacy package"]},"を使用した例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v2\",\n    \"de_name\": \"data_extension_name\",\n    \"async\": true,\n    \"records_per_batch\": 32000\n  }' \\\n  \"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["database_name"]},": クエリのソーステーブルを格納するTreasure Dataデータベース。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client_id"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client_secret"]},": Salesforce Marketing Cloud API認証情報。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["de_name"]},": Salesforce Marketing Cloudのターゲット Data Extension 名。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["async"]},": 非同期APIエクスポートを使用する場合は ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," に設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["records_per_batch"]},": バッチリクエストあたりの最大行数。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["-T presto"]},": Prestoエンジンでクエリを実行します（必要に応じてHiveなどに切り替えます）。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["最後のSQL文: エクスポートする列に合わせて ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SELECT"]}," 句を調整します。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Asynchronous API"]},"と",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enhanced package"]},"を使用した例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud_v2\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v2\",\n    \"auth_uri\": \"https://th1s1sf4k3d1nst4nc3h0st.auth.marketingcloudapis.com/\",\n    \"de_name\": \"data_extension_name\",\n    \"async\": true,\n    \"records_per_batch\": 32000\n  }' \\\n  \"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]},": Enhanced packageには ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["salesforce_marketing_cloud_v2"]}," を使用します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["auth_uri"]},": SFMCインスタンスのベース認証エンドポイント（パッケージ設定で確認できます）。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["残りのパラメータはLegacyの例と同じで、ターゲット Data Extension とクエリ出力に一致させる必要があります。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Synchronous API"]},"と",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Legacy package"]},"を使用した例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v1\",\n    \"de_name\": \"data_extension_name\",\n    \"async\": false,\n    \"continue_on_failure\": true\n  }' \\\n  \"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["auth_type"]},": レガシーSOAP認証フローを使用する場合は ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1"]}," に設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["async"]},": 同期APIに切り替えるには ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," に設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["continue_on_failure"]},": ジョブが失敗した行をスキップして処理を続行できるようにします。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Synchronous API"]},"と",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enhanced package"]},"を使用した例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud_v2\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v2\",\n    \"auth_uri\": \"https://th1s1sf4k3d1nst4nc3h0st.auth.marketingcloudapis.com/\",\n    \"de_name\": \"data_extension_name\",\n    \"async\": false,\n    \"continue_on_failure\": true\n  }' \\\n  \"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["auth_type"]},": Enhanced REST APIで認証するには ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v2"]}," のままにします。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["async"]},": エクスポートを同期的に実行するには ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," に設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["continue_on_failure"]},": 個々の行が失敗した場合でもエクスポートを続行できるようにします。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Synchronous API"]},"と",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enhanced package"]},"を使用し、存在しない場合に新しい",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sendable data extension"]},"を作成する例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud_v2\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v2\",\n    \"auth_uri\": \"https://th1s1sf4k3d1nst4nc3h0st.auth.marketingcloudapis.com/\",\n    \"de_name\": \"data_extension_name\",\n    \"create_new_de\": true,\n    \"primary_column\": \"primary_key\",\n    \"column_options\": \"col1:TEXT(100);col2:NUMBER;col3:DECIMAL(18,2);col4:DATE\",\n    \"is_sendable\": true,\n    \"sendable_column\": \"mytext\",\n    \"sendable_rule\": \"Subscriber Key\",\n    \"async\": false,\n    \"continue_on_failure\": true\n  }' \\\n  \"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create_new_de"]},": Data Extensionが存在しない場合に作成します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["primary_column"]},": 新しい Data Extension のプライマリキーフィールドを設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["column_options"]},": 新しい Data Extension の各列のデータ型を指定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["is_sendable"]},": Data Extensionをsendableとして作成します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sendable_column"]},": sendable属性として使用される列。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sendable_rule"]},": sendable列とペアになるSubscriber属性。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enhanced package"]},"を使用し、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["行ベースのリテンション"]},"を設定して新しいData Extensionを作成する例"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n  -d database_name \\\n  -r '{\n    \"type\": \"salesforce_marketing_cloud_v2\",\n    \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n    \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n    \"auth_type\": \"v2\",\n    \"auth_uri\": \"https://th1s1sf4k3d1nst4nc3h0st.auth.marketingcloudapis.com/\",\n    \"de_name\": \"data_extension_name\",\n    \"create_new_de\": true,\n    \"primary_column\": \"primary_key\",\n    \"enable_row_based_retention\": true,\n    \"retention_period_days\": 30\n  }' \\\n  \"SELECT primary_key, mytext FROM my_table\" \\\n  -T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enable_row_based_retention"]},": 新しいData Extensionで行ベースのリテンションを有効にするには ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," に設定します。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["retention_period_days"]},": 各行を保持する日数。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enable_row_based_retention"]}," が ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," の場合は必須です。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["特定のフォルダにdata extensionをエクスポートする例"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td query \\\n-d database_name \\\n-r '{\n      \"type\": \"salesforce_marketing_cloud_v2\",\n      \"client_id\": \"Th1s1s4n3x4mpl3Cl13nt1ds\",\n      \"client_secret\": \"Th1s1s4F4k3dCl13ntS3cr3t\",\n      \"auth_type\": \"v2\",\n      \"auth_uri\": \"https://th1s1sf4k3d1nst4nc3h0st.auth.marketingcloudapis.com/\",\n      \"folder_path\": \"/Data Extensions/FolderPath2/FolderPath3/FolderPath3\",\n      \"create_folder_if_not_exists\": true,\n      \"de_name\": \"data_extension_name\",\n      \"create_new_de\": true,\n      \"primary_column\": \"primary_key\",\n      \"is_sendable\": true,\n      \"sendable_column\": \"mytext\",\n      \"sendable_rule\": \"Subscriber Key\",\n      \"async\": false,\n      \"continue_on_failure\": true\n  }' \\\n\"SELECT primary_key, mytext, myinteger, mydecimal, myphone, myemail, mydate, mylocale, myboolean = 1 AS myboolean FROM my_1_million\" \\\n-T presto\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["folder_path"]},": Salesforce Marketing Cloud内の宛先フォルダパス。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create_folder_if_not_exists"]},": フォルダ階層が存在しない場合にオンデマンドで作成します。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"クエリ結果とdata-extension列名のマッピング","__idx":2},"children":["クエリ結果とData Extension列名のマッピング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["クエリ結果と Data Extension 列の間でマッピングするために、クエリで ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["as"]}," キーワードを使用できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["例1:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["サブスクライバー情報を含む以下の Data Extension があるとします:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["name: de_1 Columns: primary_key, cust_email, cust_first_name, cust_last_name, cust_phone_number"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーアカウント情報を含む以下のテーブルがあるとします:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["name: account_table"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Columns: id, login_id, first_name, last_name, contact_number"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テーブルと Data Extension の間でマッピングするために、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["as"]}," キーワードを使用した以下のクエリを使用できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT\n  id AS primary_key,\n  login_id AS cust_email,\n  first_name AS cust_first_name,\n  last_name AS cust_last_name,\n  contact_number AS cust_phone_number\nFROM account_table;\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["例2:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["電話番号（10桁の数字）を含むデータをアップロードする場合、'0'で始まる電話番号によるエラーを回避するために、以下のクエリを使用して電話番号をSTRINGとしてキャストすることもできます"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT\n  primary,\n  text,\n  CAST(number AS VARCHAR) AS number\nFROM table_name\nWHERE type = 'SUCCESS';\n","lang":"sql"},"children":[]}]},"headings":[{"value":"Salesforce Marketing Cloud V2 Export Integration Using CLI","id":"salesforce-marketing-cloud-v2-export-integration-using-cli","depth":1},{"value":"Treasure CLIでクエリを実行する","id":"treasure-cliでクエリを実行する","depth":2},{"value":"クエリ結果とData Extension列名のマッピング","id":"クエリ結果とdata-extension列名のマッピング","depth":2}],"frontmatter":{"seo":{"title":"Salesforce Marketing Cloud V2 Export Integration Using CLI"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/salesforce-marketing-cloud-v2-export-integration-using-cli","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}