Loading video...
SQL Command: INSERT
- The SQL
INSERTcommand is used to insert rows into tables in a database. It has the following syntax:INSERT INTO tblName (col1Name, col2Name, col3Name) VALUES (col1Val, col2Val, col3Val);
- The column names can be left out and values just provided as long as the values are specified according to the order in which the columns are defined in the table.
- For columns with numeric data types, values are specified with no surrounding quotation marks.
- For columns with string data types, values should be specified by surrounding them by single or double quotes.
- If a string contains a quote character, it must be escaped using the
\’or\”escape sequence.
- If a string contains a quote character, it must be escaped using the
- When inserting rows into a table with an
AUTO_INCREMENTcolumn, the valueNULLor0should be provided in order to trigger MySQL to automatically generate the ‘next’ value for the new row. - The MySQL Monitor client can be used to run multiple SQL commands contained in a text file all at once, allowing commands to be authored ‘offline’ in a text editor.
- The
<operator is used in the following manner to run the commands in a text file:mysql –u phpuser –p advanced_php < commands.sql
- Note: after the
'-p'command switch, you can specify the database to use when processing the commands in the text file. - Note: after the
'<'operator a relative or absolute path must be provided to the .sql file. - Additional Resources:
SQL Command: INSERT
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.


































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview