Professional Documents
Culture Documents
Double Click
MySql Icon
Type the Sql Administrator Password [ now you will get a prompt liks Mysql> ] then you
can start ur practical.
SELECT
VERSION();
Output
+-------------------+
| VERSION() |
+-------------------+
| 5.0.3-alpha-debug |
+-------------------+
1 row in set (0.00 sec)
2. CREATE a USER
Create
3.
user
fsd@localhost identified
by wsu12345;
Data base
a. To View the Databases
Show databases;
b. To Create a New database
create database
mscitdb;
mscitdb;
TO fsd;
Statement
SELECT
INSERT
UPDATE
Delete rows
DELETE
REFERENCES
Drop tables
DROP
CREATE, ALTER
INDEX
All privileges
ALL
fsd;
4.Tables
a. To create a Table [ first use a Database before create a table .Ex- use mscitdb; ]
Create table msctbl ( name char(30), idno int, mark1
b. To view the tables
int);
show tables;
c.
Describe mscittbl;
d.
c.
To delete a table
d.
Example =>
5. Create a view
CREATE VIEW mscitview ON mscittbl AS select idno, name FROM mscittbl;
6.
7.
Inserting the data from an Existing Table into a newly created table
Syntax :INSERT NEW_TABLE SELECT <field1, field2... | *> from OLD_TABLE
<WHERE...>;
Ex:
10.
Using the following clauses we can sort the Records in the table.
WHERE l STARTING WITH l ORDER BY l GROUP BY l HAVING
Ex.: ->
SELECT *
11.
Joining 2 Table
a.NAME, b.name
FROM
bsccstbl
a, msctbl
b;
12.
13.
String Concatenation
||
FIRSTNAME
NAME
FROM
MEZA , Messy
14.
15.
INTERSECT
INTERSECT returns only the rows found by both queries. The next
SELECT statement shows the list of players who play on both teams:
INTERSECT
SELECT * FROM