Skip to content

Commit fef2018

Browse files
committed
add dbmgmt/db_commands.rst
1 parent 021eb53 commit fef2018

3 files changed

Lines changed: 62 additions & 21 deletions

File tree

user_guide_src/source/database/metadata.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ you are currently connected to. Example:
2525

2626
.. note:: Some drivers have additional system tables that are excluded from this return.
2727

28-
db:table --show command
29-
-----------------------
30-
31-
CodeIgniter supports show list the tables in your database straight from your favorite terminal using the dedicated ``db:table --show`` command. By using this command it is assumed that the tables is existing. Otherwise, CodeIgniter will complain that tables list show has failed.
32-
33-
To start, just type ::
34-
35-
> php spark db:table --show
36-
3728
Determine If a Table Exists
3829
===========================
3930

@@ -114,18 +105,6 @@ database:
114105
- primary_key - 1 if the column is a primary key
115106
- type - the type of the column
116107

117-
db:table --metadata command
118-
---------------------------
119-
120-
CodeIgniter supports show table containing field information in your database straight from your favorite terminal using the dedicated ``db:table my_table --metadata`` command. By using this command it is assumed that the table ``my_table`` is existing. Otherwise, CodeIgniter will show that tables list for select.
121-
Also, you can use this command as ``db:table --metadata``.
122-
123-
.. note:: You can use the optional ``--desc``, ``--limit-rows``, ``--limit-field-value`` options at any time when using command ``db:table`` .
124-
125-
Command ``db:table --limit-rows 50``, for example, limits the number of rows to 50 rows.
126-
Command ``db:table --desc``, set the sort direction to "DESC".
127-
And Command ``db:table --limit-field-value 10`` limits the length of the field values to 10 characters, to prevent confusion of the table output in the terminal.
128-
129108
List the Indexes in a Table
130109
===========================
131110

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#################
2+
Database Commands
3+
#################
4+
5+
CodeIgniter provides some simple commands for databse management.
6+
7+
.. contents::
8+
:local:
9+
:depth: 2
10+
11+
*************************
12+
Showing Table Information
13+
*************************
14+
15+
List the Tables in Your Database
16+
================================
17+
18+
db:table --show
19+
---------------
20+
21+
To list all the tables in your database straight from your favorite terminal,
22+
you can use the ``db:table --show`` command::
23+
24+
> php spark db:table --show
25+
26+
When using this command it is assumed that a table exists.
27+
Otherwise, CodeIgniter will complain that the database has no tables.
28+
29+
Retrieve Some Records
30+
=====================
31+
32+
db:table
33+
--------
34+
35+
When you have a table named ``my_table``, you can see the field names and the records of a table::
36+
37+
> php spark db:table my_table
38+
39+
You can also pass a few options::
40+
41+
> php spark db:table my_table --limit-rows 50 --limit-field-value 20 --desc
42+
43+
The option ``--limit-rows 50`` limits the number of rows to 50 rows.
44+
45+
The option ``--limit-field-value 20`` limits the length of the field values to 20 characters, to prevent confusion of the table output in the terminal.
46+
47+
The option ``--desc`` sets the sort direction to "DESC".
48+
49+
Retrieve Field Metadata
50+
=======================
51+
52+
db:table --metadata
53+
-------------------
54+
55+
When you have a table named ``my_table``, you can see metadata like the column type, max length of the table with the ``--metadata`` option::
56+
57+
> php spark db:table my_table --metadata
58+
59+
When using this command it is assumed that the table exists.
60+
Otherwise, CodeIgniter will show a table list to select.
61+
Also, you can use this command as ``db:table --metadata``.

user_guide_src/source/dbmgmt/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ CodeIgniter comes with tools to restructure or seed your database.
1010
Database Manipulation with Database Forge <forge>
1111
Database Migrations <migration>
1212
Database Seeding <seeds>
13+
db_commands

0 commit comments

Comments
 (0)