Inserting data manually

Now that we have a table, let's put some data in it manually. Before we do that, here are some useful references on data manipulation within this book:

  • Chapter 5, Changing Data and Structure explains how to change data and structure
  • Chapter 7, Importing Data and Structure explains how to import data from existing files
  • Chapter 9, Performing Table and Database Operations explains how to copy data from other tables
  • Chapter 10, Benefiting from the Relational System explains the relational system (in our case, we will want to link to the author table)

For now, click on the Insert link, which will lead us to the data-entry (or edit) panel. This screen has room to enter information for two rows, that is two books in our example. This is because the default value of $cfg['InsertRows'] is 2. In the lower part of the screen, the dialog Restart insertion with 2 rows can be used if the default number of rows does not suit our needs. But beware, any data already on the screen would be lost. By default, the Ignore checkbox is ticked, which means that the second group of fields will be ignored. But as soon as we enter some information in one field of this group and exit the field, the Ignore box is automatically unchecked if JavaScript is enabled in the browser.

We can enter the following sample information for two books:

  • ISBN: 1-234567-89-0, title: A hundred years of cinema (volume 1), 600 pages, author ID: 1
  • ISBN: 1-234567-22-0, title: Future souvenirs, 200 pages, author ID: 2

We start by entering data for the first and the second rows. The Value column width obeys the maximum length for the character fields. For this example, we leave the lower drop-down selector with its default value of Insert as new row. We then click on Go to insert the data. There is a Go button after each set of columns that represent a row, and another one on the lower part of the screen. All of these have the same effect of saving the entered data, but are provided for convenience.

Inserting data manually

If our intention had been to enter data for more books after these two, we would have selected Insert another new row from the first drop-down menu before clicking on Go. This would then insert the data we have provided and reload the screen so that it's ready for us to insert more.

Data entry panel tuning for CHAR and VARCHAR

By default, phpMyAdmin displays an input field on a single line for the field types CHAR and VARCHAR. This is controlled by setting $cfg['CharEditing'] to'input'. Sometimes, we may want to insert line breaks (new lines) within the field. This can be done by changing $cfg['CharEditing'] to'textarea'. This is a global setting, and will apply to all the fields of all the tables, for all users of this copy of phpMyAdmin. In this mode, the insertion of line breaks may be done manually with the Enter key, or by copying and pasting lines of text from another on-screen source.

We can tune the number of columns and rows of this text area with:

$cfg['CharTextareaCols'] = 40;
$cfg['CharTextareaRows'] = 2;

Here, 2 for $cfg['CharTextareaRows'] means that we should be able to see at least two lines before the browser starts to display a vertical scroll bar. These settings apply to all CHAR and VARCHAR fields. Applying those settings would generate a different Insert screen, as follows:

Data entry panel tuning for CHAR and VARCHAR

Note

With this entry mode, the maximum length of each field no longer applies visually. It would be enforced by MySQL at insert time.