By editor, 29 November, 2017 Question How to get database table column names on drupal 8 ? To get database table columns names of a mysql database you can use "DESCRIBE my_table;" method. Example: get columns of the table 'node' $con = \Drupal\Core\Database\Database::getConnection(); $fields = $con->query("DESCRIBE `node`")->fetchAll(); var_dump($fields); For the new database versions you can use INFORMATION_SCHEMA (Not tested) Like: SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table'; Tags Drupal 8 Database Module Add new comment Handle database schemas on Drupal 8 Edit and Update Entity schema on drupal 8 Comments1 You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically. Using Drush We can use drush as well. drush sql-query "describe node" Reply
Comments1
Using Drush
We can use drush as well.
drush sql-query "describe node"