You are on page 1of 3

>> create

CREATE TABLE `bacth76`.`student` (


`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`per` DECIMAL NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
---------------------------------------
desc student;
---------------------------------------------
INSERT INTO bacth76.student VALUES (1, 'Ram' ,77.7);

---------------------------------------------
SELECT * FROM bacth76.student s;

SELECT * FROM bacth76.student s where per>50;

--------------------------------------------

delete row >>


DELETE FROM bacth76.student WHERE id=2;

delete coloumn..>
ALTER TABLE bacth76.student DROP COLUMN per;

delete table>>
DROP TABLE bacth76.student;
---------------------------------------------

update >>

UPDATE bacth76.student SET name='Mahesh' WHERE id=3;

------------------------------------------------

CREATE TABLE employee (


empid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(45) NOT NULL,
salary DECIMAL NOT NULL,
PRIMARY KEY (empid )
)

-----------------------------------------------------------
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 5.0.11-beta-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| bacth75 |
| bacth76 |
| dbjbk72 |
| jbkdb |
| mysql |
| test |
+--------------------+
7 rows in set (0.03 sec)

mysql> use bacth76;


Database changed
mysql> show tables;
+-------------------+
| Tables_in_bacth76 |
+-------------------+
| student |
+-------------------+
1 row in set (0.00 sec)

mysql> desc student;


+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(45) | NO | | | |
+-------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

mysql> CREATE TABLE employee (


-> empid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> name VARCHAR(45) NOT NULL,
-> salary DECIMAL NOT NULL,
-> PRIMARY KEY (`id`)
-> );
ERROR 1072 (42000): Key column 'id' doesn't exist in table
mysql> CREATE TABLE employee (
-> empid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> name VARCHAR(45) NOT NULL,
-> salary DECIMAL NOT NULL,
-> PRIMARY KEY (`id`)
-> ;)
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 5
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ')' at
line 1
mysql> desc student;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(45) | NO | | | |
+-------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

mysql> CREATE TABLE employee (


-> empid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> name VARCHAR(45) NOT NULL,
-> salary DECIMAL NOT NULL,
-> PRIMARY KEY (empid )
-> );
Query OK, 0 rows affected (0.13 sec)

mysql> desc employee;


+--------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+----------------+
| empid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(45) | NO | | | |
| salary | decimal(10,0) | NO | | | |
+--------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

mysql> insert into employee values(1,'Mr Sane',700000);


Query OK, 1 row affected (0.05 sec)

mysql> insert into employee values(2,'Mr Mane',800000);


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values(3,'Mr NaMane',900000);


Query OK, 1 row affected (0.10 sec)

mysql> select * from employee;


+-------+-----------+--------+
| empid | name | salary |
+-------+-----------+--------+
| 1 | Mr Sane | 700000 |
| 2 | Mr Mane | 800000 |
| 3 | Mr NaMane | 900000 |
+-------+-----------+--------+
3 rows in set (0.00 sec)

mysql>

----------------------------------------

You might also like