0% found this document useful (0 votes)
75 views6 pages

Ss Dbms

The document appears to be a MySQL session log that shows: 1) The user is connecting to a MySQL database called TE and exploring various tables within it like Account, Branch, Customer, and Loan. 2) The user is performing operations like describing tables, selecting data, inserting new rows, updating existing rows, and altering tables. 3) Many of the insert operations fail due to foreign key constraints between tables like Account and Branch.

Uploaded by

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

Ss Dbms

The document appears to be a MySQL session log that shows: 1) The user is connecting to a MySQL database called TE and exploring various tables within it like Account, Branch, Customer, and Loan. 2) The user is performing operations like describing tables, selecting data, inserting new rows, updating existing rows, and altering tables. 3) Many of the insert operations fail due to foreign key constraints between tables like Account and Branch.

Uploaded by

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

bash: /u01/app/oracle/product/11.2.0/xe/bin/nls_lang.

sh: No such file or directory


(base) admin1@408-7:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.42-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use TE;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| BankInfo |
| Bankinfo |
| Company_Details |
| Employee |
| MESCO |
| MESCOE |
| TE |
| TE2 |
| TECOMP |
| TEST |
| Tecomp |
| Tecomp2 |
|c |
| company |
| database1 |
| demo |
| kt |
| mysql |
| performance_schema |
| raj |
| stud |
| student |
| studentDB |
| sys |
| t1 |
| testDB |
| wt |
+--------------------+
28 rows in set (0.00 sec)

mysql> describe Account;


+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| acc_no | int(11) | NO | PRI | NULL | |
| branch_name | varchar(20) | NO | MUL | NULL | |
| balance | int(11) | NO | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> select *from Account;


+--------+-------------+---------+
| acc_no | branch_name | balance |
+--------+-------------+---------+
| 101010 | moshi | 2020 |
+--------+-------------+---------+
1 row in set (0.00 sec)

mysql> INSERT INTO Account VALUES ('128971902','pune','1010'),('2736278','ramnagar','282'),


('56161','shantanu','161');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Account`, CONSTRAINT `Account_ibfk_1` FOREIGN KEY (`branch_name`)
REFERENCES `Branch` (`branch_name`) ON DELETE CASCADE)
mysql> INSERT INTO Account VALUES('56161','shantanu','161');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Account`, CONSTRAINT `Account_ibfk_1` FOREIGN KEY (`branch_name`)
REFERENCES `Branch` (`branch_name`) ON DELETE CASCADE)
mysql> INSERT INTO Account VALUES ('3636','alandi','1010');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Account`, CONSTRAINT `Account_ibfk_1` FOREIGN KEY (`branch_name`)
REFERENCES `Branch` (`branch_name`) ON DELETE CASCADE)
mysql> dsecribe Account;
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 'dsecribe Account' at line 1
mysql> UPDATE Branch
->
-> .
-> clear
-> kyjtnhtjut
-> ;
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
mysql> UPDATE Branch
-> SET branch_name='akurdi'
-> WHERE branch_name='bhosari';
Query OK, 0 rows affected (0.02 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql> select *from Branch;


+-------------+-------------+--------+
| branch_name | branch_city | assets |
+-------------+-------------+--------+
| Indra | pune | 10 |
| mescoe | pune | 1000 |
| moshi | pune | 1001 |
| PCCOE | pune | 2020 |
+-------------+-------------+--------+
4 rows in set (0.00 sec)

mysql> Update Branch


-> SET branch_name='Indra'
-> WHERE branch_name='mescoe';
\ERROR 1062 (23000): Duplicate entry 'Indra' for key 'PRIMARY'
mysql> update Branch
-> SET branch_name='Indrayaninagar' , branch_city='munbai'
-> WHERE branch_name='mescoe';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select *from Branch;


+----------------+-------------+--------+
| branch_name | branch_city | assets |
+----------------+-------------+--------+
| Indra | pune | 10 |
| Indrayaninagar | munbai | 1000 |
| moshi | pune | 1001 |
| PCCOE | pune | 2020 |
+----------------+-------------+--------+
4 rows in set (0.00 sec)

mysql> ALTER TABLE Branch


-> ADD Branch_location
-> [FIRST | AFTER branch_city];
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 '[FIRST | AFTER branch_city]' at line 3
mysql> ALTER TABLE Branch
-> ADD Branch_location varchar(255);
Query OK, 0 rows affected (0.47 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select *from Branch;


+----------------+-------------+--------+-----------------+
| branch_name | branch_city | assets | Branch_location |
+----------------+-------------+--------+-----------------+
| Indra | pune | 10 | NULL |
| Indrayaninagar | munbai | 1000 | NULL |
| moshi | pune | 1001 | NULL |
| PCCOE | pune | 2020 | NULL |
+----------------+-------------+--------+-----------------+
4 rows in set (0.00 sec)
mysql> create view [branches ] SAS
-> select branch_name
-> from Branch
-> ;
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 '[branches ] SAS
select branch_name
from Branch' at line 1
mysql>
mysql> select Branch_name from loan;
ERROR 1146 (42S02): Table 'TE.loan' doesn't exist
mysql> show tables;
+--------------+
| Tables_in_TE |
+--------------+
| Account |
| Branch |
| Customer |
| Loan |
| Student |
+--------------+
5 rows in set (0.00 sec)

mysql> select Branch_name from Loan;


Empty set (0.00 sec)

mysql> show Loan;


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 'Loan' at line 1
mysql> Describe Loan;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| loan_no | int(11) | NO | PRI | NULL | |
| branch_name | varchar(20) | NO | MUL | NULL | |
| amount | int(11) | NO | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> insert into Loan values ('10','bavan','101010');


ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Loan`, CONSTRAINT `Loan_ibfk_1` FOREIGN KEY (`branch_name`) REFERENCES
`Branch` (`branch_name`) ON DELETE CASCADE)
mysql> describe Customer;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| cust_name | varchar(20) | NO | PRI | NULL | |
| cust_street | varchar(20) | NO | | NULL | |
| cust_city | varchar(20) | NO | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> select *from Customer;
+-----------+-------------+-----------+
| cust_name | cust_street | cust_city |
+-----------+-------------+-----------+
| shantanu | pune | pune |
+-----------+-------------+-----------+
1 row in set (0.00 sec)

mysql> insert into Customer Values ("kunal","pune","pune");


Query OK, 1 row affected (0.02 sec)

mysql> insert into Customer Values ("Nishant","pune","pune");


Query OK, 1 row affected (0.03 sec)

mysql> insert into Customer Values ("prasad","pune","pune");


Query OK, 1 row affected (0.04 sec)

mysql> insert into Customer Values ("Nikhil","pune","pune");


Query OK, 1 row affected (0.02 sec)

mysql> select *from Customer;


+-----------+-------------+-----------+
| cust_name | cust_street | cust_city |
+-----------+-------------+-----------+
| kunal | pune | pune |
| Nikhil | pune | pune |
| Nishant | pune | pune |
| prasad | pune | pune |
| shantanu | pune | pune |
+-----------+-------------+-----------+
5 rows in set (0.00 sec)

mysql> describe Account ;


+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| acc_no | int(11) | NO | PRI | NULL | |
| branch_name | varchar(20) | NO | MUL | NULL | |
| balance | int(11) | NO | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> select *from Account;


+--------+-------------+---------+
| acc_no | branch_name | balance |
+--------+-------------+---------+
| 101010 | moshi | 2020 |
+--------+-------------+---------+
1 row in set (0.00 sec)

mysql> insert into Account Values ('11','barshi','2021');


ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Account`, CONSTRAINT `Account_ibfk_1` FOREIGN KEY (`branch_name`)
REFERENCES `Branch` (`branch_name`) ON DELETE CASCADE)
mysql> insert into Account VALUES ('1010',"wagholi","1999");
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
(`TE`.`Account`, CONSTRAINT `Account_ibfk_1` FOREIGN KEY (`branch_name`)
REFERENCES `Branch` (`branch_name`) ON DELETE CASCADE)
mysql>

You might also like