There are some common mysql commands used for database connectivity
to any programming language.
1. Creation of database :- The following figure shows the mysql command line client. We have to give all commands
against the mysql prompt.
Command is :-
Create database <database name>
For example :- create database test;
Database name is a user defined
word for example in the above figure, it is test.
2. Use <database name> :- After
the successful creation of database, we have to use it for the addition of
table and data.
For example :- use test;
Now this test database is ready to
use and we can create table or insert data here.
3. Creation of table :- Now for the
creation of a table we can use the create table command as:-
mysql> create table student (rollno int,
name char(20), marks float);
4. Insertion of record in table :- when
table is created we can add data by the insert command.
For the insertion of a record in
the above table we can give command as follows :-
Insert into student values(1,’rakhee chhibber’,95);
You can use the same command after
changing the values as many as record you want to insert in a table.
5. Display of records :- to display all
the records present in a table we can use SELECT command as:-
Select
* from student;
6. Deletion of a Record :- if you want to
delete a record from a table we can use a delete record
Delete
from student; - delete all the records
from student table
Delete from student where rollno=1; :- it
will delete the record where rollno of the student is 1 but when we use this
command in any language the we use it as
Delete
from student where rollno=?.
7. Deletion of a table :- to delete a
table with structure use
DROP
table Student;
No comments:
Post a Comment