admin管理员组

文章数量:1433520

Is there any solution to get a list of default database tables in WordPress?

I have used $wpdb->tables() but even with blog argument, it returns a list that includes other tables too. (I have some plugins and they have created some more tables in database)

Is there any solution to get a list of default database tables in WordPress?

I have used $wpdb->tables() but even with blog argument, it returns a list that includes other tables too. (I have some plugins and they have created some more tables in database)

Share Improve this question asked Apr 16, 2019 at 5:35 HectorHector 6821 gold badge7 silver badges18 bronze badges 4
  • Programmatically or just to get that list? It doesn’t change as often, so hardcoding it isn’t that bad solution, I guess... – Krzysiek Dróżdż Commented Apr 16, 2019 at 5:48
  • I don't like hardcoding and writing the list manually. Searching for codes to do that. – Hector Commented Apr 16, 2019 at 5:50
  • I'm curious, what do you need it for? – Jacob Peattie Commented Apr 16, 2019 at 6:11
  • I need to show the size of each table as info for the user. But I don't like to include 3rd-party tables. – Hector Commented May 9, 2019 at 7:48
Add a comment  | 

1 Answer 1

Reset to default 1

There is no programmatic way to get a list of default tables. WordPress does not store a list of them anywhere. The closest thing there is is wp_get_db_schema(). This function returns the raw SQL used to create the default tables, but as you can see from the source, it doesn't derive it from another source, it is where the default tables are originally defined. Maybe you could parse the SQL to figure it out, but I'm not sure why you'd need to.

本文标签: wpdbHow to get a list of WordPress default database tables