Skip to content

Commit 6041b7a

Browse files
authored
Merge pull request #19 from wp-cli/db-size-readme
Regenerate README for `db size`
2 parents c1f1791 + da72295 commit 6041b7a

File tree

2 files changed

+95
-9
lines changed

2 files changed

+95
-9
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

355441
Installing this package requires WP-CLI v0.23.0 or greater. Update to the latest stable release with `wp cli update`.

src/DB_Command.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,13 @@ public function tables( $args, $assoc_args ) {
459459
/**
460460
* Display the database name and size.
461461
*
462-
* Display the database name and size for `DB_NAME` specified in wp-config.php,
463-
* defaults to a human-readable number.
462+
* Display the database name and size for `DB_NAME` specified in wp-config.php.
463+
* The size defaults to a human-readable number.
464464
*
465465
* ## OPTIONS
466466
*
467467
* [--size_format]
468-
* : Display only the database size as a number.
468+
* : Display the database size only, as a bare number.
469469
* ---
470470
* default: b
471471
* options:
@@ -526,14 +526,14 @@ public function tables( $args, $assoc_args ) {
526526
* | wp_commentmeta | 48 KB |
527527
* +-----------------------+-------+
528528
*
529-
* $ wp db size --size_format=b
530-
* 5865472
529+
* $ wp db size --size_format=b
530+
* 5865472
531531
*
532-
* $ wp db size --size_format=kb
533-
* 5728
532+
* $ wp db size --size_format=kb
533+
* 5728
534534
*
535-
* $ wp db size --size_format=mb
536-
* 6
535+
* $ wp db size --size_format=mb
536+
* 6
537537
*/
538538
public function size( $args, $assoc_args ) {
539539

0 commit comments

Comments
 (0)