0% found this document useful (0 votes)
2 views4 pages

DB Constarint Terminal

The document details a MySQL session where the user connects to the MySQL server and interacts with a database named 'db1'. It includes commands for checking the status of the server, creating a 'Project' table with foreign key constraints, and inserting records into the table. The user encounters several syntax errors during table creation and data insertion but successfully manages to create the table and insert valid records.
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)
2 views4 pages

DB Constarint Terminal

The document details a MySQL session where the user connects to the MySQL server and interacts with a database named 'db1'. It includes commands for checking the status of the server, creating a 'Project' table with foreign key constraints, and inserting records into the table. The user encounters several syntax errors during table creation and data insertion but successfully manages to create the table and insert valid records.
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/ 4

Last login: Sat Oct 19 14:06:24 on ttys000

manishpatidar@Manishs-MacBook-Pro-2 ~ % mysql -u root -p


Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.40 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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> status;
--------------
mysql Ver 9.0.1 for macos13.6 on arm64 (Homebrew)

Connection id: 20
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.40 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /tmp/mysql.sock
Binary data as: Hexadecimal
Uptime: 8 hours 57 min 7 sec

Threads: 4 Questions: 360 Slow queries: 0 Opens: 291 Flush tables: 3 Open
tables: 205 Queries per second avg: 0.011
--------------

mysql> use db1;


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> ststus;
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 'ststus'
at line 1
mysql> status;
--------------
mysql Ver 9.0.1 for macos13.6 on arm64 (Homebrew)

Connection id: 20
Current database: db1
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.40 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /tmp/mysql.sock
Binary data as: Hexadecimal
Uptime: 8 hours 57 min 26 sec

Threads: 4 Questions: 369 Slow queries: 0 Opens: 299 Flush tables: 3 Open
tables: 213 Queries per second avg: 0.011
--------------

mysql> show tables;


+---------------+
| Tables_in_db1 |
+---------------+
| student |
+---------------+
1 row in set (0.00 sec)

mysql> describe student;


+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| fullname | varchar(25) | YES | | NULL | |
| age | int | NO | | NULL | |
| email | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

mysql> CREATE TABLE Project( varchar(225) name,mysql> ;


ERROR:
No query specified

mysql> CREATE TABLE Project(


-> project_id int,
-> project_name varchar(225),
-> project_title varchar(125),
-> incharge varchar(100)
-> ;
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> CREATE TABLE Project(
-> -> project_id int,
-> -> project_name varchar(225),
-> -> project_title varchar(125),
-> -> incharge int,
->
-> ;
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 '->
project_id int,
-> project_name varchar(225),
-> project_title varcha' at line 2
mysql> CREATE TABLE Project(
-> -> -> project_id int,
-> -> -> project_name varchar(225),
-> -> -> project_title varchar(125),
-> -> -> incharge int,
-> ->
-> ;
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 '-> -
> project_id int,
-> -> project_name varchar(225),
-> ->' at line 2
mysql> CREATE TABLE Project(
-> project_id int,
-> project_name varchar(225),
-> project_date int,
-> incharge int,
-> PRIMARY KEY (project_id),
-> CONSTRAINT FK_project FOREIGN KEY (incharge) REFERENCES student(id)
-> );
Query OK, 0 rows affected (0.01 sec)

mysql> describe project;


+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| project_id | int | NO | PRI | NULL | |
| project_name | varchar(225) | YES | | NULL | |
| project_date | int | YES | | NULL | |
| incharge | int | YES | MUL | NULL | |
+--------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> insert into Project(project_id,project_name,project_date,incharge)


-> values(1,'abc',12,1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`db1`.`project`, CONSTRAINT `FK_project` FOREIGN KEY (`incharge`) REFERENCES
`student` (`id`))
mysql> insert into Project(project_id,project_name,project_date,incharge)
-> -> values(2,'abc',12,2);
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 '->
values(2,'abc',12,2)' at line 2
mysql> insert into Project(project_id,project_name,project_date,incharge)
-> values(2,'abc',12,2);
Query OK, 1 row affected (0.00 sec)

mysql> select *from Project;


+------------+--------------+--------------+----------+
| project_id | project_name | project_date | incharge |
+------------+--------------+--------------+----------+
| 2 | abc | 12 | 2 |
+------------+--------------+--------------+----------+
1 row in set (0.00 sec)

mysql> insert into Project(project_id,project_name,project_date,incharge)


-> values(3,'ab1',13,2);insert into
Project(project_id,project_name,project_date,incharge)
Query OK, 1 row affected (0.01 sec)

-> ;
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> select *from project;
+------------+--------------+--------------+----------+
| project_id | project_name | project_date | incharge |
+------------+--------------+--------------+----------+
| 2 | abc | 12 | 2 |
| 3 | ab1 | 13 | 2 |
+------------+--------------+--------------+----------+
2 rows in set (0.00 sec)

mysql> insert into Project(project_id,project_name,project_date,incharge)


-> values(4,'ab2',14,4);
Query OK, 1 row affected (0.00 sec)

mysql> select *from Project;


+------------+--------------+--------------+----------+
| project_id | project_name | project_date | incharge |
+------------+--------------+--------------+----------+
| 2 | abc | 12 | 2 |
| 3 | ab1 | 13 | 2 |
| 4 | ab2 | 14 | 4 |
+------------+--------------+--------------+----------+
3 rows in set (0.00 sec)

mysql>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy