mysql>create database student;
student;to create new database
Result:: Query OK,1 row affected <0.01>it means database is created
successfully
To Connect to the database
mysql>connect student;
This will change the database to student but on command
prompt we will have still"mysql> " prompt
Database is a logical concept it will have tables in
physicallity so now create tables in a database
mysql> create table cls(name varchar(50),rollno int(11));
Result : Query ok ,etc...a table with name cls is
created having fields name type varchar means we
can enter text of max length 50 rollno is integer having length 11int can work without integer
length also now insert data to the table Insert command
to assign values as per the structure of the table the use
following commandmysql> insert into cls
values("Parveen",122);remember this will work only if
u pass values as per the structure of the table
Note ::Where clause does not work with insert if u
understand then ok otherwise we will discuss later on
insert can work like this if u want to give value to the
particular field
mysql>insert into cls(rollno) values(234);
this will insert data in the rollno field only and
corresponding name field will be empty which is a bad
practice. This is for the knowledge of
the programmer Resutl Query ok etc...
Another format of insert command is
with set attribute
mysql> insert into cls set rollno=123, name="news";
Result :Query okin this example order does
not matter.
Tuesday, 25 November 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment