The inventory database contains the inventory table which stores the inventory information. From here you can query the details about a host or group of hosts.
First you want to log into the database system from a terminal. These examples are taken from Linux, but also apply to a Windows system.
$ sudo mysql -u root -p [sudo] password for parth: Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 31 Server version: 10.6.8-MariaDB-1:10.6.8+maria~focal mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Now that you have authenticated to the database system, you need to select which data ase you want to work with. In this case it is the inventory database, so we will 'use' it. Notice that the prompt changes to include 'inventory' as a reminder of which database you are connected to and using.
MariaDB [(none)]> use inventory; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [inventory]>
Here we can list the columns and their data definitions in the inventory table.
As seen below, this produces a list showing the columns and their basic characteristics.
'Field' is the name of each field. These are the names used when updating, inserting, or simply querying the data.
'Type' is the datatype. The format is type(size). int(11) defines the cells in this column to each be an integer with up to 11 digits total. varchar(16) is a Variable Character value made up of character/text data and can contain up to 16 characters. If fewer characters are needed, only the amount needed is used. If that is exceed, and error will occur. Others include blob (Binary Large OBject).
'Null' indicates whether the values can be NULL.
Key flags a column as being a key of some sort. Keys are values that are each unique within each table. Thye are used to associate records with others that are in other tables.
'Default' defines the default value of each cell. The null value is usually used. Null is not a specific value, it is the absence of a value. Zero and spaces are all values while a null represents the absense of a value.
'Extra' defines other characteristics. Most common is auto_increment which states that each time a new record is inserted into this table, the largest previous integer value previously used is to incremented by 1 so that each value is unique for this table.
MariaDB [inventory]> describe inventory; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | ip | varchar(16) | YES | | NULL | | | mac | varchar(18) | YES | | NULL | | | name | varchar(256) | YES | | NULL | | | location | varchar(256) | YES | | NULL | | | switch | varchar(64) | YES | | NULL | | | switchport | varchar(64) | YES | | NULL | | | ports | varchar(4096) | YES | | NULL | | | type | varchar(256) | YES | | NULL | | | sn | varchar(124) | YES | | NULL | | | os | varchar(256) | YES | | NULL | | | firmware | varchar(96) | YES | | NULL | | | dante | varchar(256) | YES | | NULL | | | ssid | varchar(256) | YES | | NULL | | | channel | varchar(8) | YES | | NULL | | | notes | varchar(4096) | YES | | NULL | | | disposition | varchar(512) | YES | | NULL | | | function | varchar(64) | YES | | NULL | | +-------------+---------------+------+-----+---------+----------------+ 18 rows in set (0.001 sec)