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

Why do Australian milk farmers need to protest supermarkets' milk price?

Russian cases: A few examples, I'm really confused

Professor being mistaken for a grad student

Is a lawful good "antagonist" effective?

Does this property of comaximal ideals always holds?

2D counterpart of std::array in C++17

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

What does it mean to make a bootable LiveUSB?

How to write cleanly even if my character uses expletive language?

What has been your most complicated TikZ drawing?

Is it possible that AIC = BIC?

Employee lack of ownership

I need to drive a 7/16" nut but am unsure how to use the socket I bought for my screwdriver

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

How could a female member of a species produce eggs unto death?

It's a yearly task, alright

Where is the 1/8 CR apprentice in Volo's Guide to Monsters?

At what level can a dragon innately cast its spells?

Define, (actually define) the "stability" and "energy" of a compound

My adviser wants to be the first author

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

Is it normal that my co-workers at a fitness company criticize my food choices?

What are the possible solutions of the given equation?

Can elves maintain concentration in a trance?



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 4 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

                              Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                              How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

                              Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її