How to create custom table in magento 2.3(via XML) by module?Module database install debugging in Magento...

Latest web browser compatible with Windows 98

Can anyone tell me why this program fails?

Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?

How to generate globally unique ids for different tables of the same database?

Is it true that real estate prices mainly go up?

How to make healing in an exploration game interesting

Instead of Universal Basic Income, why not Universal Basic NEEDS?

Why do passenger jet manufacturers design their planes with stall prevention systems?

Could the Saturn V actually have launched astronauts around Venus?

Can elves maintain concentration in a trance?

Happy pi day, everyone!

Why doesn't using two cd commands in bash script execute the second command?

When do we add an hyphen (-) to a complex adjective word?

Did CPM support custom hardware using device drivers?

Does this property of comaximal ideals always holds?

How is the Swiss post e-voting system supposed to work, and how was it wrong?

How to explain that I do not want to visit a country due to personal safety concern?

How to answer questions about my characters?

Use of プラトニック in this sentence?

Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere

Why would a flight no longer considered airworthy be redirected like this?

How can I change step-down my variable input voltage? [Microcontroller]

Good allowance savings plan?

Importance of differentiation



How to create custom table in magento 2.3(via XML) by module?


Module database install debugging in Magento 2.2Magento 2: Run a uninstall script when module is uninstalled via command line?Magento 2, how to create a test from a custom module in the new MFTF (magento functional testing framework)Need to save data while custom module installationMagento 2.3 : How to implement declarative schema in custom module404 / 500 after installing Magento 2.3Magento 2 - How to create custom files and get their URL?How to create AJAX action for POST requests in Magento 2.3?Additional Add to Cart ButtonExternal Request - Invalid Form Key Magento 2.3













1















After reading change log for Magento2.3, I come to know now onward in Magento we can add custom table via xml.



so there would be no PHP way to create a table.



So can any one tell me how can I add a custom table in via my custom module.










share|improve this question





























    1















    After reading change log for Magento2.3, I come to know now onward in Magento we can add custom table via xml.



    so there would be no PHP way to create a table.



    So can any one tell me how can I add a custom table in via my custom module.










    share|improve this question



























      1












      1








      1








      After reading change log for Magento2.3, I come to know now onward in Magento we can add custom table via xml.



      so there would be no PHP way to create a table.



      So can any one tell me how can I add a custom table in via my custom module.










      share|improve this question
















      After reading change log for Magento2.3, I come to know now onward in Magento we can add custom table via xml.



      so there would be no PHP way to create a table.



      So can any one tell me how can I add a custom table in via my custom module.







      installation magento2.3 database-schema






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 8 '18 at 16:51









      sv3n

      9,87262355




      9,87262355










      asked Dec 7 '18 at 10:35









      Shivam PastorShivam Pastor

      82




      82






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You can do that by XML.
          Check here.



          <?xml version="1.0"?>
          <!--
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          -->
          <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
          <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">
          <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="true"
          comment="Entity Id"/>
          <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>
          <column xsi:type="varchar" name="identifier" nullable="false" length="255" comment="Block String Identifier"/>
          <column xsi:type="mediumtext" name="content" nullable="true" comment="Block Content"/>
          <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
          comment="Block Creation Time"/>
          <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
          comment="Block Modification Time"/>
          <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
          default="1" comment="Is Block Active"/>
          <constraint xsi:type="primary" name="PRIMARY">
          <column name="block_id"/>
          </constraint>
          <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext">
          <column name="title"/>
          <column name="identifier"/>
          <column name="content"/>
          </index>
          </table>
          <table name="cms_block_store" resource="default" engine="innodb" comment="CMS Block To Store Linkage Table">
          <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/>
          <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
          comment="Store ID"/>
          <constraint xsi:type="primary" name="PRIMARY">
          <column name="block_id"/>
          <column name="store_id"/>
          </constraint>
          <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store"
          column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/>
          <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store"
          column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
          <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree">
          <column name="store_id"/>
          </index>
          </table>
          <table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
          <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="true"
          comment="Entity Id"/>
          <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Page Title"/>
          <column xsi:type="varchar" name="page_layout" nullable="true" length="255" comment="Page Layout"/>
          <column xsi:type="text" name="meta_keywords" nullable="true" comment="Page Meta Keywords"/>
          <column xsi:type="text" name="meta_description" nullable="true" comment="Page Meta Description"/>
          <column xsi:type="varchar" name="identifier" nullable="true" length="100" comment="Page String Identifier"/>
          <column xsi:type="varchar" name="content_heading" nullable="true" length="255" comment="Page Content Heading"/>
          <column xsi:type="mediumtext" name="content" nullable="true" comment="Page Content"/>
          <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
          comment="Page Creation Time"/>
          <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
          comment="Page Modification Time"/>
          <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
          default="1" comment="Is Page Active"/>
          <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false"
          default="0" comment="Page Sort Order"/>
          <column xsi:type="text" name="layout_update_xml" nullable="true" comment="Page Layout Update Content"/>
          <column xsi:type="varchar" name="custom_theme" nullable="true" length="100" comment="Page Custom Theme"/>
          <column xsi:type="varchar" name="custom_root_template" nullable="true" length="255"
          comment="Page Custom Template"/>
          <column xsi:type="text" name="custom_layout_update_xml" nullable="true"
          comment="Page Custom Layout Update Content"/>
          <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/>
          <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/>
          <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/>
          <constraint xsi:type="primary" name="PRIMARY">
          <column name="page_id"/>
          </constraint>
          <index name="CMS_PAGE_IDENTIFIER" indexType="btree">
          <column name="identifier"/>
          </index>
          <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext">
          <column name="title"/>
          <column name="meta_keywords"/>
          <column name="meta_description"/>
          <column name="identifier"/>
          <column name="content"/>
          </index>
          </table>
          <table name="cms_page_store" resource="default" engine="innodb" comment="CMS Page To Store Linkage Table">
          <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="false"/>
          <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
          comment="Store ID"/>
          <constraint xsi:type="primary" name="PRIMARY">
          <column name="page_id"/>
          <column name="store_id"/>
          </constraint>
          <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store"
          column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/>
          <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store"
          column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
          <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree">
          <column name="store_id"/>
          </index>
          </table>
          </schema>


          This is just example from Magento 2 CMS module which you can find from /vendor/magento/module-cms/etc/db_schema.xml file.



          In Magento 2.3 you need to define table and table fields in /Vendor/Module/etc/db_schema.xml



          1) you need provide table name, resource, engine type, comment, collation, charset, onCreate..etc: here is the basic example: <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">



          2) you need provide tables fileds type, name,nullable,length,length..etc here is the basic example: <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>



          3) You need to provide tables constraint type,name,column,referenceTable,referenceColumn..etc for primary OR foreign key here is the basic example with primary key: <constraint xsi:type="primary" name="PRIMARY"><column name="block_id"/><column name="store_id"/></constraint>



          4) As basic last you need to provide index with name, indexType ..etc here is the basic example with index: <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"><column name="title"/><column name="identifier"/><column name="content"/></index>



          You can learn more about table schema here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html



          You can learn more about data and schema patches here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html






          share|improve this answer

































            1














            An example has been mentioned this reference doc. You also refer the core files of Magento v2.3.0 for learning.



            <table name="catalog_product_entity_datetime" resource="default" engine="innodb"
            comment="Catalog Product Datetime Attribute Backend Table">
            <column xsi:type="int" name="value_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Value ID"/>
            <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Attribute ID"/>
            <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/>
            <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
            <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/>
            <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="value_id"/>
            </constraint>
            <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/>
            <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
            <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
            <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID">
            <column name="entity_id"/>
            <column name="attribute_id"/>
            <column name="store_id"/>
            </constraint>
            <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree">
            <column name="attribute_id"/>
            </index>
            <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree">
            <column name="store_id"/>
            </index>
            </table>





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f252784%2fhow-to-create-custom-table-in-magento-2-3via-xml-by-module%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              You can do that by XML.
              Check here.



              <?xml version="1.0"?>
              <!--
              /**
              * Copyright © Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              -->
              <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
              <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">
              <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="true"
              comment="Entity Id"/>
              <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>
              <column xsi:type="varchar" name="identifier" nullable="false" length="255" comment="Block String Identifier"/>
              <column xsi:type="mediumtext" name="content" nullable="true" comment="Block Content"/>
              <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
              comment="Block Creation Time"/>
              <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
              comment="Block Modification Time"/>
              <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
              default="1" comment="Is Block Active"/>
              <constraint xsi:type="primary" name="PRIMARY">
              <column name="block_id"/>
              </constraint>
              <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext">
              <column name="title"/>
              <column name="identifier"/>
              <column name="content"/>
              </index>
              </table>
              <table name="cms_block_store" resource="default" engine="innodb" comment="CMS Block To Store Linkage Table">
              <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/>
              <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
              comment="Store ID"/>
              <constraint xsi:type="primary" name="PRIMARY">
              <column name="block_id"/>
              <column name="store_id"/>
              </constraint>
              <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store"
              column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/>
              <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store"
              column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
              <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree">
              <column name="store_id"/>
              </index>
              </table>
              <table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
              <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="true"
              comment="Entity Id"/>
              <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Page Title"/>
              <column xsi:type="varchar" name="page_layout" nullable="true" length="255" comment="Page Layout"/>
              <column xsi:type="text" name="meta_keywords" nullable="true" comment="Page Meta Keywords"/>
              <column xsi:type="text" name="meta_description" nullable="true" comment="Page Meta Description"/>
              <column xsi:type="varchar" name="identifier" nullable="true" length="100" comment="Page String Identifier"/>
              <column xsi:type="varchar" name="content_heading" nullable="true" length="255" comment="Page Content Heading"/>
              <column xsi:type="mediumtext" name="content" nullable="true" comment="Page Content"/>
              <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
              comment="Page Creation Time"/>
              <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
              comment="Page Modification Time"/>
              <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
              default="1" comment="Is Page Active"/>
              <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false"
              default="0" comment="Page Sort Order"/>
              <column xsi:type="text" name="layout_update_xml" nullable="true" comment="Page Layout Update Content"/>
              <column xsi:type="varchar" name="custom_theme" nullable="true" length="100" comment="Page Custom Theme"/>
              <column xsi:type="varchar" name="custom_root_template" nullable="true" length="255"
              comment="Page Custom Template"/>
              <column xsi:type="text" name="custom_layout_update_xml" nullable="true"
              comment="Page Custom Layout Update Content"/>
              <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/>
              <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/>
              <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/>
              <constraint xsi:type="primary" name="PRIMARY">
              <column name="page_id"/>
              </constraint>
              <index name="CMS_PAGE_IDENTIFIER" indexType="btree">
              <column name="identifier"/>
              </index>
              <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext">
              <column name="title"/>
              <column name="meta_keywords"/>
              <column name="meta_description"/>
              <column name="identifier"/>
              <column name="content"/>
              </index>
              </table>
              <table name="cms_page_store" resource="default" engine="innodb" comment="CMS Page To Store Linkage Table">
              <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="false"/>
              <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
              comment="Store ID"/>
              <constraint xsi:type="primary" name="PRIMARY">
              <column name="page_id"/>
              <column name="store_id"/>
              </constraint>
              <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store"
              column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/>
              <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store"
              column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
              <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree">
              <column name="store_id"/>
              </index>
              </table>
              </schema>


              This is just example from Magento 2 CMS module which you can find from /vendor/magento/module-cms/etc/db_schema.xml file.



              In Magento 2.3 you need to define table and table fields in /Vendor/Module/etc/db_schema.xml



              1) you need provide table name, resource, engine type, comment, collation, charset, onCreate..etc: here is the basic example: <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">



              2) you need provide tables fileds type, name,nullable,length,length..etc here is the basic example: <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>



              3) You need to provide tables constraint type,name,column,referenceTable,referenceColumn..etc for primary OR foreign key here is the basic example with primary key: <constraint xsi:type="primary" name="PRIMARY"><column name="block_id"/><column name="store_id"/></constraint>



              4) As basic last you need to provide index with name, indexType ..etc here is the basic example with index: <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"><column name="title"/><column name="identifier"/><column name="content"/></index>



              You can learn more about table schema here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html



              You can learn more about data and schema patches here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html






              share|improve this answer






























                2














                You can do that by XML.
                Check here.



                <?xml version="1.0"?>
                <!--
                /**
                * Copyright © Magento, Inc. All rights reserved.
                * See COPYING.txt for license details.
                */
                -->
                <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
                <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">
                <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="true"
                comment="Entity Id"/>
                <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>
                <column xsi:type="varchar" name="identifier" nullable="false" length="255" comment="Block String Identifier"/>
                <column xsi:type="mediumtext" name="content" nullable="true" comment="Block Content"/>
                <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Block Creation Time"/>
                <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Block Modification Time"/>
                <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                default="1" comment="Is Block Active"/>
                <constraint xsi:type="primary" name="PRIMARY">
                <column name="block_id"/>
                </constraint>
                <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext">
                <column name="title"/>
                <column name="identifier"/>
                <column name="content"/>
                </index>
                </table>
                <table name="cms_block_store" resource="default" engine="innodb" comment="CMS Block To Store Linkage Table">
                <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
                <constraint xsi:type="primary" name="PRIMARY">
                <column name="block_id"/>
                <column name="store_id"/>
                </constraint>
                <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store"
                column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/>
                <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store"
                column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree">
                <column name="store_id"/>
                </index>
                </table>
                <table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
                <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="true"
                comment="Entity Id"/>
                <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Page Title"/>
                <column xsi:type="varchar" name="page_layout" nullable="true" length="255" comment="Page Layout"/>
                <column xsi:type="text" name="meta_keywords" nullable="true" comment="Page Meta Keywords"/>
                <column xsi:type="text" name="meta_description" nullable="true" comment="Page Meta Description"/>
                <column xsi:type="varchar" name="identifier" nullable="true" length="100" comment="Page String Identifier"/>
                <column xsi:type="varchar" name="content_heading" nullable="true" length="255" comment="Page Content Heading"/>
                <column xsi:type="mediumtext" name="content" nullable="true" comment="Page Content"/>
                <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Page Creation Time"/>
                <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Page Modification Time"/>
                <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                default="1" comment="Is Page Active"/>
                <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false"
                default="0" comment="Page Sort Order"/>
                <column xsi:type="text" name="layout_update_xml" nullable="true" comment="Page Layout Update Content"/>
                <column xsi:type="varchar" name="custom_theme" nullable="true" length="100" comment="Page Custom Theme"/>
                <column xsi:type="varchar" name="custom_root_template" nullable="true" length="255"
                comment="Page Custom Template"/>
                <column xsi:type="text" name="custom_layout_update_xml" nullable="true"
                comment="Page Custom Layout Update Content"/>
                <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/>
                <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/>
                <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/>
                <constraint xsi:type="primary" name="PRIMARY">
                <column name="page_id"/>
                </constraint>
                <index name="CMS_PAGE_IDENTIFIER" indexType="btree">
                <column name="identifier"/>
                </index>
                <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext">
                <column name="title"/>
                <column name="meta_keywords"/>
                <column name="meta_description"/>
                <column name="identifier"/>
                <column name="content"/>
                </index>
                </table>
                <table name="cms_page_store" resource="default" engine="innodb" comment="CMS Page To Store Linkage Table">
                <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
                <constraint xsi:type="primary" name="PRIMARY">
                <column name="page_id"/>
                <column name="store_id"/>
                </constraint>
                <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store"
                column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/>
                <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store"
                column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree">
                <column name="store_id"/>
                </index>
                </table>
                </schema>


                This is just example from Magento 2 CMS module which you can find from /vendor/magento/module-cms/etc/db_schema.xml file.



                In Magento 2.3 you need to define table and table fields in /Vendor/Module/etc/db_schema.xml



                1) you need provide table name, resource, engine type, comment, collation, charset, onCreate..etc: here is the basic example: <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">



                2) you need provide tables fileds type, name,nullable,length,length..etc here is the basic example: <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>



                3) You need to provide tables constraint type,name,column,referenceTable,referenceColumn..etc for primary OR foreign key here is the basic example with primary key: <constraint xsi:type="primary" name="PRIMARY"><column name="block_id"/><column name="store_id"/></constraint>



                4) As basic last you need to provide index with name, indexType ..etc here is the basic example with index: <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"><column name="title"/><column name="identifier"/><column name="content"/></index>



                You can learn more about table schema here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html



                You can learn more about data and schema patches here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html






                share|improve this answer




























                  2












                  2








                  2







                  You can do that by XML.
                  Check here.



                  <?xml version="1.0"?>
                  <!--
                  /**
                  * Copyright © Magento, Inc. All rights reserved.
                  * See COPYING.txt for license details.
                  */
                  -->
                  <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
                  <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">
                  <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="true"
                  comment="Entity Id"/>
                  <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>
                  <column xsi:type="varchar" name="identifier" nullable="false" length="255" comment="Block String Identifier"/>
                  <column xsi:type="mediumtext" name="content" nullable="true" comment="Block Content"/>
                  <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Block Creation Time"/>
                  <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Block Modification Time"/>
                  <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                  default="1" comment="Is Block Active"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="block_id"/>
                  </constraint>
                  <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext">
                  <column name="title"/>
                  <column name="identifier"/>
                  <column name="content"/>
                  </index>
                  </table>
                  <table name="cms_block_store" resource="default" engine="innodb" comment="CMS Block To Store Linkage Table">
                  <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                  <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="block_id"/>
                  <column name="store_id"/>
                  </constraint>
                  <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store"
                  column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/>
                  <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store"
                  column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                  <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree">
                  <column name="store_id"/>
                  </index>
                  </table>
                  <table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
                  <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="true"
                  comment="Entity Id"/>
                  <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Page Title"/>
                  <column xsi:type="varchar" name="page_layout" nullable="true" length="255" comment="Page Layout"/>
                  <column xsi:type="text" name="meta_keywords" nullable="true" comment="Page Meta Keywords"/>
                  <column xsi:type="text" name="meta_description" nullable="true" comment="Page Meta Description"/>
                  <column xsi:type="varchar" name="identifier" nullable="true" length="100" comment="Page String Identifier"/>
                  <column xsi:type="varchar" name="content_heading" nullable="true" length="255" comment="Page Content Heading"/>
                  <column xsi:type="mediumtext" name="content" nullable="true" comment="Page Content"/>
                  <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Page Creation Time"/>
                  <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Page Modification Time"/>
                  <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                  default="1" comment="Is Page Active"/>
                  <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false"
                  default="0" comment="Page Sort Order"/>
                  <column xsi:type="text" name="layout_update_xml" nullable="true" comment="Page Layout Update Content"/>
                  <column xsi:type="varchar" name="custom_theme" nullable="true" length="100" comment="Page Custom Theme"/>
                  <column xsi:type="varchar" name="custom_root_template" nullable="true" length="255"
                  comment="Page Custom Template"/>
                  <column xsi:type="text" name="custom_layout_update_xml" nullable="true"
                  comment="Page Custom Layout Update Content"/>
                  <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/>
                  <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/>
                  <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="page_id"/>
                  </constraint>
                  <index name="CMS_PAGE_IDENTIFIER" indexType="btree">
                  <column name="identifier"/>
                  </index>
                  <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext">
                  <column name="title"/>
                  <column name="meta_keywords"/>
                  <column name="meta_description"/>
                  <column name="identifier"/>
                  <column name="content"/>
                  </index>
                  </table>
                  <table name="cms_page_store" resource="default" engine="innodb" comment="CMS Page To Store Linkage Table">
                  <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                  <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="page_id"/>
                  <column name="store_id"/>
                  </constraint>
                  <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store"
                  column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/>
                  <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store"
                  column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                  <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree">
                  <column name="store_id"/>
                  </index>
                  </table>
                  </schema>


                  This is just example from Magento 2 CMS module which you can find from /vendor/magento/module-cms/etc/db_schema.xml file.



                  In Magento 2.3 you need to define table and table fields in /Vendor/Module/etc/db_schema.xml



                  1) you need provide table name, resource, engine type, comment, collation, charset, onCreate..etc: here is the basic example: <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">



                  2) you need provide tables fileds type, name,nullable,length,length..etc here is the basic example: <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>



                  3) You need to provide tables constraint type,name,column,referenceTable,referenceColumn..etc for primary OR foreign key here is the basic example with primary key: <constraint xsi:type="primary" name="PRIMARY"><column name="block_id"/><column name="store_id"/></constraint>



                  4) As basic last you need to provide index with name, indexType ..etc here is the basic example with index: <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"><column name="title"/><column name="identifier"/><column name="content"/></index>



                  You can learn more about table schema here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html



                  You can learn more about data and schema patches here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html






                  share|improve this answer















                  You can do that by XML.
                  Check here.



                  <?xml version="1.0"?>
                  <!--
                  /**
                  * Copyright © Magento, Inc. All rights reserved.
                  * See COPYING.txt for license details.
                  */
                  -->
                  <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
                  <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">
                  <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="true"
                  comment="Entity Id"/>
                  <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>
                  <column xsi:type="varchar" name="identifier" nullable="false" length="255" comment="Block String Identifier"/>
                  <column xsi:type="mediumtext" name="content" nullable="true" comment="Block Content"/>
                  <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Block Creation Time"/>
                  <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Block Modification Time"/>
                  <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                  default="1" comment="Is Block Active"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="block_id"/>
                  </constraint>
                  <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext">
                  <column name="title"/>
                  <column name="identifier"/>
                  <column name="content"/>
                  </index>
                  </table>
                  <table name="cms_block_store" resource="default" engine="innodb" comment="CMS Block To Store Linkage Table">
                  <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                  <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="block_id"/>
                  <column name="store_id"/>
                  </constraint>
                  <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store"
                  column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/>
                  <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store"
                  column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                  <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree">
                  <column name="store_id"/>
                  </index>
                  </table>
                  <table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
                  <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="true"
                  comment="Entity Id"/>
                  <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Page Title"/>
                  <column xsi:type="varchar" name="page_layout" nullable="true" length="255" comment="Page Layout"/>
                  <column xsi:type="text" name="meta_keywords" nullable="true" comment="Page Meta Keywords"/>
                  <column xsi:type="text" name="meta_description" nullable="true" comment="Page Meta Description"/>
                  <column xsi:type="varchar" name="identifier" nullable="true" length="100" comment="Page String Identifier"/>
                  <column xsi:type="varchar" name="content_heading" nullable="true" length="255" comment="Page Content Heading"/>
                  <column xsi:type="mediumtext" name="content" nullable="true" comment="Page Content"/>
                  <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Page Creation Time"/>
                  <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                  comment="Page Modification Time"/>
                  <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                  default="1" comment="Is Page Active"/>
                  <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false"
                  default="0" comment="Page Sort Order"/>
                  <column xsi:type="text" name="layout_update_xml" nullable="true" comment="Page Layout Update Content"/>
                  <column xsi:type="varchar" name="custom_theme" nullable="true" length="100" comment="Page Custom Theme"/>
                  <column xsi:type="varchar" name="custom_root_template" nullable="true" length="255"
                  comment="Page Custom Template"/>
                  <column xsi:type="text" name="custom_layout_update_xml" nullable="true"
                  comment="Page Custom Layout Update Content"/>
                  <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/>
                  <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/>
                  <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="page_id"/>
                  </constraint>
                  <index name="CMS_PAGE_IDENTIFIER" indexType="btree">
                  <column name="identifier"/>
                  </index>
                  <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext">
                  <column name="title"/>
                  <column name="meta_keywords"/>
                  <column name="meta_description"/>
                  <column name="identifier"/>
                  <column name="content"/>
                  </index>
                  </table>
                  <table name="cms_page_store" resource="default" engine="innodb" comment="CMS Page To Store Linkage Table">
                  <column xsi:type="smallint" name="page_id" padding="6" unsigned="false" nullable="false" identity="false"/>
                  <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
                  <constraint xsi:type="primary" name="PRIMARY">
                  <column name="page_id"/>
                  <column name="store_id"/>
                  </constraint>
                  <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store"
                  column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/>
                  <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store"
                  column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                  <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree">
                  <column name="store_id"/>
                  </index>
                  </table>
                  </schema>


                  This is just example from Magento 2 CMS module which you can find from /vendor/magento/module-cms/etc/db_schema.xml file.



                  In Magento 2.3 you need to define table and table fields in /Vendor/Module/etc/db_schema.xml



                  1) you need provide table name, resource, engine type, comment, collation, charset, onCreate..etc: here is the basic example: <table name="cms_block" resource="default" engine="innodb" comment="CMS Block Table">



                  2) you need provide tables fileds type, name,nullable,length,length..etc here is the basic example: <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Block Title"/>



                  3) You need to provide tables constraint type,name,column,referenceTable,referenceColumn..etc for primary OR foreign key here is the basic example with primary key: <constraint xsi:type="primary" name="PRIMARY"><column name="block_id"/><column name="store_id"/></constraint>



                  4) As basic last you need to provide index with name, indexType ..etc here is the basic example with index: <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"><column name="title"/><column name="identifier"/><column name="content"/></index>



                  You can learn more about table schema here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html



                  You can learn more about data and schema patches here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 5 mins ago

























                  answered Dec 7 '18 at 10:37









                  kunjkunj

                  2,6602423




                  2,6602423

























                      1














                      An example has been mentioned this reference doc. You also refer the core files of Magento v2.3.0 for learning.



                      <table name="catalog_product_entity_datetime" resource="default" engine="innodb"
                      comment="Catalog Product Datetime Attribute Backend Table">
                      <column xsi:type="int" name="value_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Value ID"/>
                      <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Attribute ID"/>
                      <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/>
                      <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
                      <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/>
                      <constraint xsi:type="primary" referenceId="PRIMARY">
                      <column name="value_id"/>
                      </constraint>
                      <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/>
                      <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
                      <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                      <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID">
                      <column name="entity_id"/>
                      <column name="attribute_id"/>
                      <column name="store_id"/>
                      </constraint>
                      <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree">
                      <column name="attribute_id"/>
                      </index>
                      <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree">
                      <column name="store_id"/>
                      </index>
                      </table>





                      share|improve this answer




























                        1














                        An example has been mentioned this reference doc. You also refer the core files of Magento v2.3.0 for learning.



                        <table name="catalog_product_entity_datetime" resource="default" engine="innodb"
                        comment="Catalog Product Datetime Attribute Backend Table">
                        <column xsi:type="int" name="value_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Value ID"/>
                        <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Attribute ID"/>
                        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/>
                        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
                        <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/>
                        <constraint xsi:type="primary" referenceId="PRIMARY">
                        <column name="value_id"/>
                        </constraint>
                        <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/>
                        <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
                        <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                        <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID">
                        <column name="entity_id"/>
                        <column name="attribute_id"/>
                        <column name="store_id"/>
                        </constraint>
                        <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree">
                        <column name="attribute_id"/>
                        </index>
                        <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree">
                        <column name="store_id"/>
                        </index>
                        </table>





                        share|improve this answer


























                          1












                          1








                          1







                          An example has been mentioned this reference doc. You also refer the core files of Magento v2.3.0 for learning.



                          <table name="catalog_product_entity_datetime" resource="default" engine="innodb"
                          comment="Catalog Product Datetime Attribute Backend Table">
                          <column xsi:type="int" name="value_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Value ID"/>
                          <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Attribute ID"/>
                          <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/>
                          <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
                          <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/>
                          <constraint xsi:type="primary" referenceId="PRIMARY">
                          <column name="value_id"/>
                          </constraint>
                          <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/>
                          <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
                          <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                          <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID">
                          <column name="entity_id"/>
                          <column name="attribute_id"/>
                          <column name="store_id"/>
                          </constraint>
                          <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree">
                          <column name="attribute_id"/>
                          </index>
                          <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree">
                          <column name="store_id"/>
                          </index>
                          </table>





                          share|improve this answer













                          An example has been mentioned this reference doc. You also refer the core files of Magento v2.3.0 for learning.



                          <table name="catalog_product_entity_datetime" resource="default" engine="innodb"
                          comment="Catalog Product Datetime Attribute Backend Table">
                          <column xsi:type="int" name="value_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Value ID"/>
                          <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Attribute ID"/>
                          <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/>
                          <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
                          <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/>
                          <constraint xsi:type="primary" referenceId="PRIMARY">
                          <column name="value_id"/>
                          </constraint>
                          <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/>
                          <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
                          <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
                          <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID">
                          <column name="entity_id"/>
                          <column name="attribute_id"/>
                          <column name="store_id"/>
                          </constraint>
                          <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree">
                          <column name="attribute_id"/>
                          </index>
                          <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree">
                          <column name="store_id"/>
                          </index>
                          </table>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 7 '18 at 12:06









                          PriyankPriyank

                          5,22241950




                          5,22241950






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f252784%2fhow-to-create-custom-table-in-magento-2-3via-xml-by-module%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                              How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                              夢乃愛華...