0% found this document useful (0 votes)
14 views

Mysql

Uploaded by

heymiss288
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Mysql

Uploaded by

heymiss288
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

use nancy;

Database changed
mysql> create table employee(Empno varchar(3) primary key,Ename varchar(25),salary
decimal(8,2) NOT NULL,Bonus int(5),
-> Dept id varchar(3));
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 'id
varchar(3))' at line 2
mysql> create table employee(Empno varchar(3) primary key,ename varchar(25),salary
decimal(8,2) NOT NULL,/
-> bonus int(5),Dept id varchar(3));
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 '/
bonus int(5),Dept id varchar(3))' at line 1
mysql> create table employee(empno varchar(3) Primary key,ename varchar(25),salary
decimal(8,2) NOT NULL,bonus int(5),Deptid varchar(3));
Query OK, 0 rows affected, 1 warning (0.05 sec)

mysql> desc employee;


+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| empno | varchar(3) | NO | PRI | NULL | |
| ename | varchar(25) | YES | | NULL | |
| salary | decimal(8,2) | NO | | NULL | |
| bonus | int | YES | | NULL | |
| Deptid | varchar(3) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> insert into employee values('101','Aaliya',10000,234,'D02');


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values('102','Aman',20000,235,'D03');


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values('103','Aaradhya',30000,236,'D04');


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values('104','Ansh',40000,237,'D05');


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values('105','Anu',50000,238,'D06');


Query OK, 1 row affected (0.01 sec)

mysql> select * from employee;


+-------+----------+----------+-------+--------+
| empno | ename | salary | bonus | Deptid |
+-------+----------+----------+-------+--------+
| 101 | Aaliya | 10000.00 | 234 | D02 |
| 102 | Aman | 20000.00 | 235 | D03 |
| 103 | Aaradhya | 30000.00 | 236 | D04 |
| 104 | Ansh | 40000.00 | 237 | D05 |
| 105 | Anu | 50000.00 | 238 | D06 |
+-------+----------+----------+-------+--------+
5 rows in set (0.00 sec)

mysql> insert into employee values('106','Sameer',NULL,239,'D07');


ERROR 1048 (23000): Column 'salary' cannot be null
mysql> insert into employee values('102','Daizy',60000,239,'D07');
ERROR 1062 (23000): Duplicate entry '102' for key 'employee.PRIMARY'
mysql>

You might also like