Site icon TestingDocs.com

Basic MySQL Commands

Overview

In this page, we will learn some basic MySQL commands used in database testing.

Connect to a database

https://www.testingdocs.com/working-with-mysql-command-line/

Create Table

To create a table, you must use the CREATE TABLE command and specify the table name and fields. The following command creates the department:

CREATE TABLE department (
dept_name char(20) NOT NULL,
dept_number numeric(1) NOT NULL,
mgrSSN numeric(9) NOT NULL,
mgrStartDate date NOT NULL,
PRIMARY KEY (dept_number),
UNIQUE (dept_name)
);

 

Note that we have written SQL keywords in capital letters. It is a coding standard of writing an SQL query. This is to enhance the readability of the SQL query to others. SQL is NOT case sensitive.

DESCRIBE statement

https://www.testingdocs.com/mysql-describe-statement/

INSERT

Since you’ve created a table, you can begin inserting data to it. The
INSERT command is shown below to add a record to the table. The values must be listed in exactly the same order as the fields. Each value is separated by a comma, and all VARCHAR & CHAR data type values must be enclosed in single quotation marks.

INSERT INTO department VALUES 
(‘Quality Assurance’,1,111223333,’1994-05-24′);

 

SELECT statement

SELECT statement is used to retrieve data from the database. To learn about the SELECT statement:

https://www.testingdocs.com/mysql-select-statement/

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

 

Exit mobile version