0% found this document useful (0 votes)
45 views10 pages

Mysql 2

MySQL commands are used to create tables, insert records, make queries, and perform other operations in a database. The main commands are CREATE TABLE to create a table with specified columns and data types, INSERT INTO to insert records into a table by specifying column names and values, and SELECT to query the table and retrieve specific columns and rows that match conditions. Functions like COUNT, AVG, MAX, MIN, and SUM can be used to perform calculations on aggregate data from multiple rows.

Uploaded by

Avi Dahiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views10 pages

Mysql 2

MySQL commands are used to create tables, insert records, make queries, and perform other operations in a database. The main commands are CREATE TABLE to create a table with specified columns and data types, INSERT INTO to insert records into a table by specifying column names and values, and SELECT to query the table and retrieve specific columns and rows that match conditions. Functions like COUNT, AVG, MAX, MIN, and SUM can be used to perform calculations on aggregate data from multiple rows.

Uploaded by

Avi Dahiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

MYSQL

COMMANDS
CREATING TABLE
• CREATE TABLE:- Used to create table in Mysql
• CREATE TABLE <tablename>
(<columnname1> <datatype> (<size>),
<columnname2> <datatype> (<size>),
……..
);
Create Table
• Eg:-
• CREATE TABLE Student
(rollno int(4),
name varchar(15),
marks decimal(5,2));
INSERTING RECORDS IN TABLE
• INSERT INTO:- Used to insert record in a table.
• INSERT INTO <tablename> VALUES (value1,value2,
…..);
• INSERT INTO <tablename>
(<columnname1>,<columnname2>) VALUES
(<value1>,<value2>);
• Eg:-
• INSERT INTO student VALUES (1,”ABC”,85.5);
• INSERT INTO student (rollno,marks) VALUES (2,90);
Queries in mysql
• SELECT statement:- Used to make queries in
mysql. SELECT * from student;
• DISTINCT:- Used to eliminate duplicate data in
query. SELECT DISTINCT name from student;
• DESCRIBE:- Used to view the structure of
table. DESCRIBE student;
• Column Alias:- “AS”
SELECT rollno as “rollnumber” from student;
CONDITIONS
• WHERE clause:- used to specify condition with
select statement
• Condition based on a range:-
BETWEEN:- Used for making ranges checks in
queries
• Condition based on list:-
IN:- Used for selecting values from a list of values
• Conditions based on pattern matching:-
LIKE:-Used for making character comparison using
percentage(%) and underscore(_)
FUNCTIONS
• A function is a special type of predefined
command set that performs some operations
and return a single value.
Eg pow(2,3)  8
• Single Row Functions
• Multiple Row Functions
Single Row Functions
• String Functions:- Lcase(), Ucase(), Concat(),
Instr(), Length(), Rtrim(), Ltrim(), Substr()
• Numeric Functions:- Round(), Truncate(),
Pow(), Mod()
• Date Functions:-Date(), Now(), Year() etc.
Aggregate Functions
• AVG():- Returns the average value of numeric column.
• COUNT():- Returns the number of rows that match the
criteria in where clause
• MAX():- Returns the largest value of the selected
column
• MIN():- Returns the smallest value of the selected
column
• SUM():- Returns the total sum of a numeric column
• COUNT(*):- Returns total number of records from table
Assignment
• Q.1 What is SQL? What are different categories of commands available
in SQL?
• Q.2 Differentiate between CHAR and VARCHAR datatypes.
• Q.3 Differentiate between DDL and DML commands.
• Q.4 Write two examples of DBMS software.
• Q.5What is meant by NULL value in Mysql?
• Q.6A table Club has 4 rows and 3 columns. What is the degree and
cardinality of the table if 2 more records are added to it?
• Q.7 What do you mean by table level constraints and column level
constraints? Explain with example.
• Q.8 What is a data type? Name some data types available in Mysql.
• How would you calculate 13*15 in mysql?
• Write mysql command to display the list of existing database.

You might also like