{"id":72476,"date":"2020-04-05T12:42:31","date_gmt":"2020-04-05T09:42:31","guid":{"rendered":"https:\/\/www.drakauskas.lt\/blog\/?p=72476"},"modified":"2026-08-05T16:39:06","modified_gmt":"2026-08-05T13:39:06","slug":"create-database-table-with-wordpres-function","status":"publish","type":"post","link":"https:\/\/www.drakauskas.lt\/blog\/en\/create-database-table-with-wordpres-function\/","title":{"rendered":"Create database table with Wordpres function"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">An example of creating a table in Mysql database with WordPress function. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* id and COLUMNNAME are the columns of new database table which name is new_table_name ) *\/\n  \nglobal $wpdb;\n \n$charset_collate = $wpdb->get_charset_collate();\n$table_name = $wpdb->prefix . 'new_table_name';\n \n$sql = \"CREATE TABLE $table_name (\n    id mediumint(9) NOT NULL AUTO_INCREMENT,\n    COLUMNNAME longtext NOT NULL,\n    UNIQUE KEY id (id)\n) $charset_collate;\";\n \n \ndbDelta( $sql );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>An example of creating a table in Mysql database with WordPress function.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[237],"tags":[419,426],"class_list":["post-72476","post","type-post","status-publish","format-standard","hentry","category-wordpress-en","tag-mysql-en","tag-wpdb-en"],"_links":{"self":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/comments?post=72476"}],"version-history":[{"count":1,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72476\/revisions"}],"predecessor-version":[{"id":72477,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72476\/revisions\/72477"}],"wp:attachment":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/media?parent=72476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/categories?post=72476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/tags?post=72476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}