{"id":947,"date":"2015-10-28T14:15:12","date_gmt":"2015-10-28T14:15:12","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=947"},"modified":"2015-10-28T18:46:24","modified_gmt":"2015-10-28T18:46:24","slug":"drupal-custom-module-create-database-table-during-installation","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/","title":{"rendered":"Drupal Custom Module &#8211; Create database table during installation"},"content":{"rendered":"<p>In our previous article, we have shown how can you <a href=\"http:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/\">create your own drupal custom module<\/a>. Now you&#8217;ll learn the advanced functionality for your custom module. <\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\" alt=\"drupal-custom-module-create-table-into-database-during-installation-by-codexworld\" width=\"624\" height=\"324\" class=\"alignnone size-full wp-image-948\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png 624w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-300x156.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-350x182.png 350w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-320x166.png 320w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-380x197.png 380w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-200x104.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld-346x180.png 346w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/div>\n<p>Assume that, your module needs the database tables for storing the module related data. In this tutorial, we&#8217;ll discuss the process of creating a table into the database during module installation. Your module needs a <code>.install<\/code> file, which helps your module to create required table when the module is first enabled and removed when the module is uninstalled. Also, you can update the database table based on your module&#8217;s updated version. <\/p>\n<h2>Creating .install file<\/h2>\n<p>In Drupal 7, a <code>.install<\/code> file is used to create database tables and fields, and inserting the data. <code>.install<\/code> file also is used to update the table structure and contents. <code>.install<\/code> file is a PHP file with different extension.<\/p>\n<p>Create a <code>.install<\/code> file (mymodule.install) into the root directory of your module. Using this file, we&#8217;ll create a <b>subscribers<\/b> table into the database for storing the website subscriber&#8217;s data.<\/p>\n<h2>Define hook_schema()<\/h2>\n<p><code>hook_schema()<\/code> holds an array structure for representing one or more tables and their related keys and indexes. <\/p>\n<p>Define <code>hook_schema<\/code> for subscribers table and write the following code.<\/p>\n<pre><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">mymodule_schema<\/span><span style=\"color: #007700\">(){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$schema<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscribers'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'The&nbsp;table&nbsp;for&nbsp;storing&nbsp;the&nbsp;subscriber&nbsp;data.'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'fields'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'id'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'The&nbsp;primary&nbsp;identifier&nbsp;for&nbsp;subscriber.'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'serial'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'unsigned'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'name'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscriber&nbsp;name.'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'varchar'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'length'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">255<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'default'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'email'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscriber&nbsp;email.'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'varchar'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'length'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">255<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'default'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'subscription_date'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscription&nbsp;date&nbsp;time(yyyy-mm-dd&nbsp;H:i:s).'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'varchar'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'mysql_type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'DATETIME'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'status'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscriber&nbsp;status(1=Unblock,0=Block).'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'int'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'length'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'default'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'primary&nbsp;key'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$schema<\/span><span style=\"color: #007700\">;<br \/>}<\/span><\/pre>\n<p><code>hook_schema()<\/code> is invoked before <code>hook_install()<\/code> and after <code>hook_uninstall()<\/code> is invoked. If the tables declared by <code>hook_schema()<\/code>, then the tables will be automatically created when the module is first enabled and removed when the module is uninstalled.<\/p>\n<h2>Using hook_update_N()<\/h2>\n<p><b>hook_update_N<\/b> function is used to add, update or delete database tables, fields or contents at the time of updating your module. For example, In the latest version of your module you want to add a new column at the <b>subscribers<\/b> table. <\/p>\n<p><b>hook_update_N<\/b> function would be the following.<\/p>\n<pre><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">mymodule_update_2<\/span><span style=\"color: #007700\">()&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ret&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">db_add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ret<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'subscribers'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'country'<\/span><span style=\"color: #007700\">,&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscriber&nbsp;country.'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'varchar'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'default'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'length'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">255<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'not&nbsp;null'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$ret<\/span><span style=\"color: #007700\">;<br \/>}<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In our previous article, we have shown how can you create your own drupal custom module. Now you&#8217;ll learn the advanced functionality for your custom module. Assume that, your module needs the database tables for <\/p>\n","protected":false},"author":1,"featured_media":948,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[42,69,68],"class_list":["post-947","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-drupal","tag-drupal","tag-drupal-7-module","tag-drupal-module","cat-11-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Drupal Custom Module - Create database table during installation - CodexWorld<\/title>\n<meta name=\"description\" content=\"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Drupal Custom Module - Create database table during installation - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-28T14:15:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-10-28T18:46:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"624\" \/>\n\t<meta property=\"og:image:height\" content=\"324\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Drupal Custom Module &#8211; Create database table during installation\",\"datePublished\":\"2015-10-28T14:15:12+00:00\",\"dateModified\":\"2015-10-28T18:46:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/\"},\"wordCount\":292,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\",\"keywords\":[\"Drupal\",\"Drupal 7 Module\",\"Drupal Module\"],\"articleSection\":[\"Drupal\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/\",\"name\":\"Drupal Custom Module - Create database table during installation - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\",\"datePublished\":\"2015-10-28T14:15:12+00:00\",\"dateModified\":\"2015-10-28T18:46:24+00:00\",\"description\":\"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png\",\"width\":624,\"height\":324,\"caption\":\"drupal-custom-module-create-table-into-database-during-installation-by-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-create-database-table-during-installation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Drupal Custom Module &#8211; Create database table during installation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Drupal Custom Module - Create database table during installation - CodexWorld","description":"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/","og_locale":"en_US","og_type":"article","og_title":"Drupal Custom Module - Create database table during installation - CodexWorld","og_description":"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.","og_url":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-10-28T14:15:12+00:00","article_modified_time":"2015-10-28T18:46:24+00:00","og_image":[{"width":624,"height":324,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Drupal Custom Module &#8211; Create database table during installation","datePublished":"2015-10-28T14:15:12+00:00","dateModified":"2015-10-28T18:46:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/"},"wordCount":292,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","keywords":["Drupal","Drupal 7 Module","Drupal Module"],"articleSection":["Drupal"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/","url":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/","name":"Drupal Custom Module - Create database table during installation - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","datePublished":"2015-10-28T14:15:12+00:00","dateModified":"2015-10-28T18:46:24+00:00","description":"Drupal Custom Module tutorial - Create table into the database during module installation. Learn how to create a table during the module installation.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","width":624,"height":324,"caption":"drupal-custom-module-create-table-into-database-during-installation-by-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-create-database-table-during-installation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Drupal Custom Module &#8211; Create database table during installation"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-create-table-into-database-during-installation-by-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-fh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=947"}],"version-history":[{"count":3,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/947\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/947\/revisions\/952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/948"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}