0% found this document useful (0 votes)
6 views12 pages

MySQL Database Management Commands

The document provides a detailed interaction with a MySQL database, including commands to show databases, create a new database named 'SCHOOL', and create a table called 'student'. It also demonstrates inserting data into the 'student' table and executing various queries to retrieve and filter that data. The MySQL server version is 8.0.43, and the document includes examples of SQL syntax and error handling.

Uploaded by

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

MySQL Database Management Commands

The document provides a detailed interaction with a MySQL database, including commands to show databases, create a new database named 'SCHOOL', and create a table called 'student'. It also demonstrates inserting data into the 'student' table and executing various queries to retrieve and filter that data. The MySQL server version is 8.0.43, and the document includes examples of SQL syntax and error handling.

Uploaded by

suchitas726
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 8.0.43 MySQL Community Server - GPL

Copyright (c) 2000, 2025, 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> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.07 sec)

mysql> use mysql;

Database changed

mysql> show tables;

+------------------------------------------------------+

| Tables_in_mysql |

+------------------------------------------------------+

| columns_priv |
| component |

| db |

| default_roles |

| engine_cost |

| func |

| general_log |

| global_grants |

| gtid_executed |

| help_category |

| help_keyword |

| help_relation |

| help_topic |

| innodb_index_stats |

| innodb_table_stats |

| ndb_binlog_index |

| password_history |

| plugin |

| procs_priv |

| proxies_priv |

| replication_asynchronous_connection_failover |

| replication_asynchronous_connection_failover_managed |

| replication_group_configuration_version |

| replication_group_member_actions |

| role_edges |

| server_cost |

| servers |

| slave_master_info |

| slave_relay_log_info |

| slave_worker_info |

| slow_log |

| tables_priv |
| time_zone |

| time_zone_leap_second |

| time_zone_name |

| time_zone_transition |

| time_zone_transition_type |

| user |

+------------------------------------------------------+

38 rows in set (0.04 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

mysql> SHOW DATABASES;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)


mysql> USE SYS;

Database changed

mysql> SHOW TABLES;

+-----------------------------------------------+

| Tables_in_sys |

+-----------------------------------------------+

| host_summary |

| host_summary_by_file_io |

| host_summary_by_file_io_type |

| host_summary_by_stages |

| host_summary_by_statement_latency |

| host_summary_by_statement_type |

| innodb_buffer_stats_by_schema |

| innodb_buffer_stats_by_table |

| innodb_lock_waits |

| io_by_thread_by_latency |

| io_global_by_file_by_bytes |

| io_global_by_file_by_latency |

| io_global_by_wait_by_bytes |

| io_global_by_wait_by_latency |

| latest_file_io |

| memory_by_host_by_current_bytes |

| memory_by_thread_by_current_bytes |

| memory_by_user_by_current_bytes |

| memory_global_by_current_bytes |

| memory_global_total |

| metrics |

| processlist |

| ps_check_lost_instrumentation |

| schema_auto_increment_columns |

| schema_index_statistics |
| schema_object_overview |

| schema_redundant_indexes |

| schema_table_lock_waits |

| schema_table_statistics |

| schema_table_statistics_with_buffer |

| schema_tables_with_full_table_scans |

| schema_unused_indexes |

| session |

| session_ssl_status |

| statement_analysis |

| statements_with_errors_or_warnings |

| statements_with_full_table_scans |

| statements_with_runtimes_in_95th_percentile |

| statements_with_sorting |

| statements_with_temp_tables |

| sys_config |

| user_summary |

| user_summary_by_file_io |

| user_summary_by_file_io_type |

| user_summary_by_stages |

| user_summary_by_statement_latency |

| user_summary_by_statement_type |

| version |

| wait_classes_global_by_avg_latency |

| wait_classes_global_by_latency |

| waits_by_host_by_latency |

| waits_by_user_by_latency |

| waits_global_by_latency |

| x$host_summary |

| x$host_summary_by_file_io |

| x$host_summary_by_file_io_type |
| x$host_summary_by_stages |

| x$host_summary_by_statement_latency |

| x$host_summary_by_statement_type |

| x$innodb_buffer_stats_by_schema |

| x$innodb_buffer_stats_by_table |

| x$innodb_lock_waits |

| x$io_by_thread_by_latency |

| x$io_global_by_file_by_bytes |

| x$io_global_by_file_by_latency |

| x$io_global_by_wait_by_bytes |

| x$io_global_by_wait_by_latency |

| x$latest_file_io |

| x$memory_by_host_by_current_bytes |

| x$memory_by_thread_by_current_bytes |

| x$memory_by_user_by_current_bytes |

| x$memory_global_by_current_bytes |

| x$memory_global_total |

| x$processlist |

| x$ps_digest_95th_percentile_by_avg_us |

| x$ps_digest_avg_latency_distribution |

| x$ps_schema_table_statistics_io |

| x$schema_flattened_keys |

| x$schema_index_statistics |

| x$schema_table_lock_waits |

| x$schema_table_statistics |

| x$schema_table_statistics_with_buffer |

| x$schema_tables_with_full_table_scans |

| x$session |

| x$statement_analysis |

| x$statements_with_errors_or_warnings |

| x$statements_with_full_table_scans |
| x$statements_with_runtimes_in_95th_percentile |

| x$statements_with_sorting |

| x$statements_with_temp_tables |

| x$user_summary |

| x$user_summary_by_file_io |

| x$user_summary_by_file_io_type |

| x$user_summary_by_stages |

| x$user_summary_by_statement_latency |

| x$user_summary_by_statement_type |

| x$wait_classes_global_by_avg_latency |

| x$wait_classes_global_by_latency |

| x$waits_by_host_by_latency |

| x$waits_by_user_by_latency |

| x$waits_global_by_latency |

+-----------------------------------------------+

101 rows in set (0.02 sec)

mysql> CREATE DATABASE SCHOOL;

Query OK, 1 row affected (0.03 sec)

mysql> SHOW DATABASES;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| school |

| sys |

+--------------------+

5 rows in set (0.00 sec)


mysql> CREAT DDD;

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 'CREAT DDD' at line 1

mysql> USE SCHOOL;

Database changed

mysql> SHOW TABLES;

Empty set (0.00 sec)

mysql> create table student(admno integer,name varchar(20),city varchar(10),marks integer,dob


date);

Query OK, 0 rows affected (0.06 sec)

mysql> create table student1(admno integr,name varchar(20),city varchar(10),marks integer,dob


date);

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 'integr,name varchar(20),city
varchar(10),marks integer,dob date)' at line 1

mysql> show tables;

+------------------+

| Tables_in_school |

+------------------+

| student |

+------------------+

1 row in set (0.00 sec)

mysql> desc student;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| admno | int | YES | | NULL | |

| name | varchar(20) | YES | | NULL | |

| city | varchar(10) | YES | | NULL | |


| marks | int | YES | | NULL | |

| dob | date | YES | | NULL | |

+-------+-------------+------+-----+---------+-------+

5 rows in set (0.02 sec)

mysql> insert into student values(1,"ABC","mahasamund",45,"2000/12/06");

Query OK, 1 row affected, 1 warning (0.04 sec)

mysql> insert into student values(2,"XYZ","Saraipali",55,"2001/12/06");

Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> insert into student values(3,"pqr","Raipur",60,"2002/10/01");

Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> select * from student;

+-------+------+------------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+------------+-------+------------+

| 1 | ABC | mahasamund | 45 | 2000-12-06 |

| 2 | XYZ | Saraipali | 55 | 2001-12-06 |

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+------------+-------+------------+

3 rows in set (0.00 sec)

mysql> select name from student;

+------+

| name |

+------+

| ABC |

| XYZ |

| pqr |
+------+

3 rows in set (0.00 sec)

mysql> select * from student;

+-------+------+------------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+------------+-------+------------+

| 1 | ABC | mahasamund | 45 | 2000-12-06 |

| 2 | XYZ | Saraipali | 55 | 2001-12-06 |

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+------------+-------+------------+

3 rows in set (0.00 sec)

mysql> select name,dob from student;

+------+------------+

| name | dob |

+------+------------+

| ABC | 2000-12-06 |

| XYZ | 2001-12-06 |

| pqr | 2002-10-01 |

+------+------------+

3 rows in set (0.00 sec)

mysql> select dob city from student;

+------------+

| city |

+------------+

| 2000-12-06 |

| 2001-12-06 |

| 2002-10-01 |

+------------+
3 rows in set (0.00 sec)

mysql> select dob ,city from student;

+------------+------------+

| dob | city |

+------------+------------+

| 2000-12-06 | mahasamund |

| 2001-12-06 | Saraipali |

| 2002-10-01 | Raipur |

+------------+------------+

3 rows in set (0.00 sec)

mysql> select * from student;

+-------+------+------------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+------------+-------+------------+

| 1 | ABC | mahasamund | 45 | 2000-12-06 |

| 2 | XYZ | Saraipali | 55 | 2001-12-06 |

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+------------+-------+------------+

3 rows in set (0.00 sec)

mysql> select * from student where city="Raipur";

+-------+------+--------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+--------+-------+------------+

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+--------+-------+------------+

1 row in set (0.02 sec)

mysql> select * from student where admno>2;


+-------+------+--------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+--------+-------+------------+

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+--------+-------+------------+

1 row in set (0.00 sec)

mysql> select * from student where admno>=2;

+-------+------+-----------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+-----------+-------+------------+

| 2 | XYZ | Saraipali | 55 | 2001-12-06 |

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+-----------+-------+------------+

2 rows in set (0.00 sec)

mysql> select * from student where admno>=2 and admno<=5;

+-------+------+-----------+-------+------------+

| admno | name | city | marks | dob |

+-------+------+-----------+-------+------------+

| 2 | XYZ | Saraipali | 55 | 2001-12-06 |

| 3 | pqr | Raipur | 60 | 2002-10-01 |

+-------+------+-----------+-------+------------+

2 rows in set (0.00 sec)

Common questions

Powered by AI

The available databases in the MySQL server are 'information_schema', 'mysql', 'performance_schema', and 'sys'. The presence of 'information_schema' suggests it is used for metadata storage about other databases, 'mysql' typically houses user privileges and access control metadata, 'performance_schema' is instrumental for performance diagnostics, and 'sys' provides simplified views and functions to help database administrators.

Fields like 'admno', 'marks' use 'int' as they store numerical data, and 'name', 'city' use 'varchar' to allow variable-length text. The 'dob' field uses 'date' to store dates efficiently. These choices optimize storage as 'integers' are efficient for whole numbers, 'varchar' saves space by not storing excess empty space, and 'date' is tailored for date-specific operations.

The 'performance_schema' is crucial for collecting performance metrics, offering insights into system behavior and bottleneck analysis. 'sys' builds on this by providing user-friendly views and functions, allowing easier interpretation of 'performance_schema' data, thus aiding in database optimization and management.

The errors like 'CREAT DDD' and 'integr' instead of 'CREATE' and 'integer' will result in SQL syntax errors, preventing the creation of databases or tables. These errors disrupt database querying as the commands are improperly executed. Rectifying these involves correcting the spelling to 'CREATE DATABASE' and 'integer' to ensure the SQL commands adhere to proper syntax.

The 'sys' database facilitates simplified administration by providing pre-defined views and functions that present information from the 'performance_schema' in a more accessible manner. Practically, this aids in routine tasks like diagnosing performance issues, tracking usage statistics, and aiding in maintenance decisions without needing deep technical expertise.

The 'student' table data can be used to analyze performance trends by conducting descriptive statistics on 'marks' to measure data like mean, median, distribution, and identify high/low performers. Comparing 'marks' over time (using 'dob' as a proxy if representing academic years) can show trends over cohorts.

Tables like 'user', 'db', and 'columns_priv' in the 'mysql' database store information about user accounts, privileges per database, and specific column access. They are essential for implementing access control, ensuring only authorized users can perform specific actions, thus maintaining data security and preventing unauthorized access.

Scalability issues may arise from full table scans in queries as the table grows, leading to slow performance. Lack of indexes besides the primary key could exacerbate this, particularly if queries frequently filter on 'city' or 'marks'. Adding appropriate indexes could mitigate these risks and enhance performance.

The executed queries show correct usage of filters and selections, indicating reliable data retrieval under current scenarios. Improvements include ensuring consistent data types and handling errors robustly in queries to prevent future data retrieval issues, particularly with more complex operations.

The 'SHOW DATABASES' command can return different results as new databases are created or existing ones deleted, reflecting dynamic database management practices. This variation highlights ongoing database developments and maintenance activities, indicating active data management and organizational adaptability.

You might also like