Documente Academic
Documente Profesional
Documente Cultură
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create table customers(ID int primary key, NAME varchar(30), AGE int,
ADDRESS varchar(30), SALARY float);
ERROR 1046 (3D000): No database selected
mysql> use lab4
Database changed
mysql> create table customers(ID int primary key, NAME varchar(30), AGE int,
ADDRESS varchar(30), SALARY float);
Query OK, 0 rows affected (0.71 sec)
mysql> insert into customers values (1, "Ramesh", 32, "Ahmedabad", 2000), (2,
"Khilan",25,"Delhi",1500),(3,"Kaushik",23,"Kota",2000),
(4,"Chaitali",25,"Mumbai",6500);
Query OK, 4 rows affected (0.13 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> insert into customers values (5, "Hardik", 27, "Bhopal", 8500), (6,
"Komal",22,"MP",4500),(7,"Muffy",24,"Indore",10000);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> update customers set salary=salary*0.25 where age in (select age from
customers where age>27);
ERROR 1093 (HY000): You can't specify target table 'customers' for update in FROM
clause
mysql> update customers set salary = salary*0.25 where age in (select age from
customers where age>27);
ERROR 1093 (HY000): You can't specify target table 'customers' for update in FROM
clause
mysql> update table customers set salary = salary*0.25 where age in (select age
from customers where age>27);
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 'table
customers set salary = salary*0.25 where age in (select age from customers' at line
1
mysql> update customers set salary ="salary*0.25" where age in (select age from
customers where age>27);
ERROR 1093 (HY000): You can't specify target table 'customers' for update in FROM
clause
mysql> update customers set salary = salary*0.25 where age in (select age from
customers where age>27);
ERROR 1093 (HY000): You can't specify target table 'customers' for update in FROM
clause
mysql> select age from customers where age>25;
+------+
| age |
+------+
| 32 |
| 27 |
+------+
2 rows in set (0.00 sec)
mysql> update customers set salary = salary*0.25 where age in (select age from
customers_view where age>27);
ERROR 1146 (42S02): Table 'lab4.customers_view' doesn't exist
mysql> update customers set salary = salary*0.25 where age in (select age from
customer_view where age>27);
ERROR 1443 (HY000): The definition of table 'customer_view' prevents operation
UPDATE on table 'customers'.
mysql> show tables;
+----------------+
| Tables_in_lab4 |
+----------------+
| customer_view |
| customers |
+----------------+
2 rows in set (0.04 sec)
mysql> update customers set salary = salary*0.25 where age in (select age from
customer_view where age>27);
ERROR 1443 (HY000): The definition of table 'customer_view' prevents operation
UPDATE on table 'customers'.
mysql> create database practise;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> create table tblProduct(ProductID int primary key, Name Varchar(30),
UnitPrice int, CatID int, EntryDate date and time, ExpiryDate date and time);
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 'and
time, ExpiryDate date and time)' at line 1
mysql> create table tblProduct(ProductID int primary key, Name Varchar(30),
UnitPrice int, CatID int, EntryDate datetime, ExpiryDate datetime);
Query OK, 0 rows affected (0.10 sec)
mysql> create table tblOrder(OrderId int primary key, ProductID int, Quantity int,
price int,CustomerID int, ContactNo int);
Query OK, 0 rows affected (0.11 sec)
mysql>