MySQL pdf class 10 note HSLC final exam


    CHAPTER -3

    Computer Science HSLC SEBA Board

    Database Part - II

    MySQL 

    I.                     MULTI CHOICE QUESTIONS:

     

    1.       The command used to modify the content of a table is:

    a)       ALTER TABLE

    b)      SELECT

    c)       UPDATE

     

    2.       The command used to display the table structure is:

    a)       DISPLAY

    b)      STRUCTURE

    d)      DESCRIBE

     

    3.       A table name should begin with:

    a)       Number

    e)      Alphabets

    b)      Symbol

     

    4.       The command used to delete the database physical:

    a)       DELETE

    b)      ERASE

    f)        DROP

     

    5.       This wildcard character allows finding a match for any string of any length, including zero length

    a)       *

    b)      %

    c)       #

     

    6.       This operator displays only those records that do not satisfy the specific condition,

    a)       AND

    b)      OR

    c)       NOT

     

    7.       What is the full form of DBMS:

    a)       Database Management System

    b)      Database Managerial System

    c)       Developbase Management Sysetem

     

    8.       What is the full form of RDMBS

    a)       Relational Database Managerial System

    b)      Relational Database Management System

    c)       Rational Database Management Systyem

    9.       The command used to modify the content of a table:

    a)       ALTER TABLE

    b)      INSERT

    c)       UPDATE

     

    10.   The MySQL query that will display the structure of the Customer’ table is:

    a)       DISPLAY customer

    b)      DESCRIBE customer

    c)       SHOW customer

     

     

     

    II.              FILL IN THE BLANKS:

     

    1.       MySQL is name after co-founder Michael Widenius’s daughter, My.

    2.       The number of rows denotes the cardinality of the table.

    3.       The number of column denote the Degree of the table.

    4.       Reserve words are not allowed in a table name.

    5.       A MySQL statement is terminated by a semicolon(;).

    6.       The underscore wildcare allows finding a match for any single character.

     

     

    III.                 SHORT ANSWER:

     

    1.       Name the company which created MySQL and when?

    MySQL was created by Swedish company MySQL AB in 1995.

     

    2.       After whom, MySQL is named?

    My SQL is named after Michel Widenius’s Daughter My.

     

    3.       Name some commands that com under Data Definition language (DDL).

    CREAT, ALTER, DROP

     

    4.       Name some commands that come under Data Manipulation Language (DML).

    INSERT, UPDATE, DELETE

     

    5.       Name some commands that come under Transaction Control Language (TCL).

    COMMIT, ROLLBACK, SAVEPOINT

     

    6.       How is a MySQL statement is terminated?

    MySQL statement is terminated by semicolon (;)

     

    7.       What does the Primary Key indicate?

    The primary key indicates uniqueness of each record.

     

    8.       What command is used to modify the structure of an existing table?

    DESCRIBE <table_name>

     

    9.       Name the command with which one can change the data type of an existing column.

    ALTER TABLE command with MODIFY clause.

    10.   What is the use of % (percentage sign)?

    The wildcard character % is used with like clause to represent zero or more characters.

     

    11.   What is the use of _ (underscore sign)?

    The _ (underscore sign) is used to represent one, single character.

     

    12.   Name the three logical operators.

    The three logical operators are:

    i)                    AND

    ii)                   OR

    iii)                 NOT

     

    IV.             ANSWER THE FOLLOWING QUESTIONS:

     

    1.       Who were the developer of MySQL?

    Michael Widenius, David Axmark, and Allan Larsson were the developers of MySQL who work together since 1980x.

     

    2.       Why MySQl becoming so popular? Give two reasons.

    MySQL is becoming popular because

    i)                    It released under open source, so anyone can use it for free.

    ii)                   It is a platform dependent language, it supports in many operating system with different programing language.

     

    3.       What is Constraint? Name any two constraints.

    Constrain are some rules that help ensure the validity of the data while entering data in a table. The Constraint in MySQl are:

    i)                    PRIMARY KEY

    ii)                   NT NULL

    iii)                 FOREIGN KEY

    iv)                 UNIQUE

    v)                   ENUM

    vi)                 SET

     

    4.       Give Example of DML commands:

    These statements are used to for managing the data. Example:

    i)                    INSERT is used to add data to the table

    Ex : INSERT INTO student VALUES( 1, ‘John’, ‘2014-03-25’)

    ii)                   SELECT is used to view the table with the inserted record

    Ex: SELECT FROM student;

    iii)                 CREATE TABLE is used to create a table in a database.

    CREATE TABLE[IF NOT EXIST] <table_name>;

     

    5.       What are characteristic by which you can determine the data type of MySQL?

    The data type in MySQL can be determined by the following characteristic:

    i)                    The number of bytes it takes for storage

    ii)                   The kind of value it represents

     

     

    6.       What is the query to display the table structure?

    The query to display the table structure is:

    DESCRIBE <table_name>;

    OR

    DESC <table_name>;

     

     

    7.       What is the query to display all the records in a table:

    SELECT*FROM<table_name>;

     

     

    8.       List the Arithmetic Operators used in MySQL.

    Arithmetic Operators used in MySQL are:

    Operators

    Meaning

    +

    Addition

    -

    Subtraction

    \

    Division

    *

    Multiplication

    %

    Modulus or Remainder

     

     

    9.       List the Relational Operators used in MySQL.

    Relational Operators used in MySQL are:

    Operators

    Meaning

    =

    Equal to

    < > or! =

    Not equal to

    < 

    Less than

    < 

    Greater Than

    <=

    Less than equal to

    >=

    Greater than equal to

     

     

    10.   Differentiate between COUNT(*) and COUNT.

    The different between COUNT(*) and COUNT is that:

    COUNT(*) returns the number of values in specified column / expressions.

    Whereas,

    COUNT() returns the number of rows in a table.

     

    11.   What are the rules for naming a table in MySQL?

    The rules for naming a table in MySQL are stated below:

    i)                    A table name can have a maximum of 30 characters.

    ii)                   It can contain characters A- Z, a-z, and number 0 -9

    iii)                 A table name should begin with an alphabet.

    iv)                 The special characters _(underscore) is allowed. It is used for joining two words.

    v)                   Reserved words are not allowed. For example, CREATE, SELECT and ALTER etc.

     

     

     

     

    12.   Explain the five categories of SQL commands?

    The five categories of SQL commands are:

    i)                    DDL

    The statement in DDL are used to define database structure. These include CREATE, ALTER, DROP, TRUNCATE & COMMNET commands.

    ii)                   DML

    These statements are used for managing the data. These include SELECT, DELETE, INSERT, UPDATE, which are used to retrieve and manipulating data in MySQL.

    iii)                 TCL

    The statements are used to manage the changes made by DML statement. These Include COMMIT, ROLLBACK< and SAVEPOINT commands.

    iv)                 DCL

    These statements are used to give/withdraw access privileges to the database user. These include GRANT and REVOKE Commands.

    v)                   DQL

    This include SELECT, SHOW, and HELP commands. SELECT is the main DQL statement.

     

    13.   How many types of SQL commands are there? Name them.

    There are five type of SQL commands. They are:

    Name

    Full Form

    i)                    DDL

    Data Definition Language

    ii)                   DML

    Data Manipulation Language

    iii)                 DCL

    Data Control Language

    iv)                 TCL

    Transaction Control Language

    v)                   DQL

    Data Query Language

     

    14.   What is the use of DML?

    DML is used to modify, add / delete the database. It is responsible for all form of changes in a database.

     

    15.   Cite the reason why one must delete a database with due care.

    Deleting a database means deleting the entire data and all related object inside the database. And deleting is permanent, so, one must delete a database with due care.

     

    16.   What is the syntax of CREATE TABLE command?

    The syntax of CREATE TABLE command is:

    CREATE TABLE <table_name>(<column_name1><data_type>[size][primary key],<column_name2><data_type>[size][null][not null] ……..);

     

    17.   What is NOT NULL?

    NOT NULL constraint tells us that we cannot store a null value in that column.

     

    18.   What is PRIMARY KEY?

    PRIMARY KEY is a field which can uniquely identify each row in a table. PRIMARY KEY constraint is used to specify a field as primary key table.

     

    19.   What is the syntax for creating a new column in a table?

    The syntax for creating a new column in a table is:

    ALTER TABLE <table_naem> ADD <new_columnName><datatype> (size);

     

    20.   Write the command to add new column to the table at specific location in the table structure.

    The command to add new column to the table at specific location in the table structure is:

    ALTER TABLE <table_name> ADD (<new column_nam> <datatype>(size), <new column_name><datatype>)AFTER<column_name>;

    For adding the columns at the first position we use FIRST

    Command instead of after.

     

    21.   Name the format with which one can change the data type of an existing column by using the ALTER TABLE command.

    We use MODIFY command to change the data type of an existing column by using the ALTER TABLE command.

    The syntax to use MODIFY command is:

    ALTER TABLE <table_name> MODIFY<column_Name> <new datatype>(<new_size>);

     

    22.   How can one rename an existing column by using the ALTER TABLE command?

    We can use CHANGE command to rename and existing column by using ALTER TABLE command. The syntax to rename is:

    ALTER TABLE <table_name> CHANGE<OldName> <newName><datatype>(<size>);

     

    23.   What is the meaning of dropping a column? What is the syntax of this command?

    Dropping a column means to delete a column from a table. The syntax of DROP command is:

    ALTER TABLE <table_name> DROP <columnName>;

     

    24.   Name the way to retrieve a data from the table.

    The way to retrieve a data from the table are:

    i)                    Select column and all the rows

    ii)                   Select rows and all the columns.

    iii)                 Select rows and select column.

     

    25.   What is the query syntax of displaying the selected set of columns of selected rows from a table?

    SELECT<column1>, <column2>, FROM <table_name> WHERE <condition>;

     

    26.   Write a brief note on Arithmetic Operators.

    An Arithmetic Operators performing data manipulation operation with the commands SELECT, UPDATE< and DELETE. The arithmetic operators we used in MySQL are Addition(+), Subtraction(-), Division(/), Multiplication(*), and Modulus(%).

     

    27.   Write a brief note on Relational Operators?

    Relational Operators are used with WHERE command to display selected rows based on condition.

     

    28.   What is the use of shorting?

    Sorting is used for arranging data in large database. Sorting can be done in MySQL by using ORDER BY clause. The data can be display either ascending or descending order.

     

     

    29.   What is the use of the DELETE command?

    DELETE commands deletes rows that satisfy the condition specified in WHERE clause and return the number of deleted records.

     

    30.   What is the use of UPDATE command in the tables?

    The UPDATE command is used to change or modify data values in a table. The UPDATE command updates all the specified columns, in every row in the table. We use SET command along with UPDATE command to change the value.