@@ -350,6 +350,92 @@ Defaults to all tables registered to the $wpdb database handler.
350350 $ wp db export --tables=$(wp db tables --url=sub.example.com --format=csv)
351351 Success: Exported to wordpress_dbase.sql
352352
353+
354+
355+ ### wp db size
356+
357+ Display the database name and size.
358+
359+ ~~~
360+ wp db size [--size_format] [--tables] [--format] [--scope=<scope>] [--network] [--all-tables-with-prefix] [--all-tables]
361+ ~~~
362+
363+ Display the database name and size for ` DB_NAME ` specified in wp-config.php.
364+ The size defaults to a human-readable number.
365+
366+ ** OPTIONS**
367+
368+ [--size_format]
369+ Display the database size only, as a bare number.
370+ ---
371+ default: b
372+ options:
373+ - b (bytes)
374+ - kb (kilobytes)
375+ - mb (megabytes)
376+ ---
377+
378+ [--tables]
379+ Display each table name and size instead of the database size.
380+
381+ [--format]
382+ table, csv, json
383+ ---
384+ default: table
385+ options:
386+ - table
387+ - csv
388+ - json
389+ ---
390+
391+ [--scope=<scope>]
392+ Can be all, global, ms_global, blog, or old tables. Defaults to all.
393+
394+ [--network]
395+ List all the tables in a multisite install. Overrides --scope=<scope>.
396+
397+ [--all-tables-with-prefix]
398+ List all tables that match the table prefix even if not registered on $wpdb. Overrides --network.
399+
400+ [--all-tables]
401+ List all tables in the database, regardless of the prefix, and even if not registered on $wpdb. Overrides --all-tables-with-prefix.
402+
403+ ** EXAMPLES**
404+
405+ $ wp db size
406+ +-------------------+------+
407+ | Name | Size |
408+ +-------------------+------+
409+ | wordpress_default | 6 MB |
410+ +-------------------+------+
411+
412+ $ wp db size --tables
413+ +-----------------------+-------+
414+ | Name | Size |
415+ +-----------------------+-------+
416+ | wp_users | 64 KB |
417+ | wp_usermeta | 48 KB |
418+ | wp_posts | 80 KB |
419+ | wp_comments | 96 KB |
420+ | wp_links | 32 KB |
421+ | wp_options | 32 KB |
422+ | wp_postmeta | 48 KB |
423+ | wp_terms | 48 KB |
424+ | wp_term_taxonomy | 48 KB |
425+ | wp_term_relationships | 32 KB |
426+ | wp_termmeta | 48 KB |
427+ | wp_commentmeta | 48 KB |
428+ +-----------------------+-------+
429+
430+ $ wp db size --size_format=b
431+ 5865472
432+
433+ $ wp db size --size_format=kb
434+ 5728
435+
436+ $ wp db size --size_format=mb
437+ 6
438+
353439## Installing
354440
355441Installing this package requires WP-CLI v0.23.0 or greater. Update to the latest stable release with ` wp cli update ` .
0 commit comments