Skip to main content

MySQL CRUD Operations Creating Table Read Update and Drop


mysql> drop table if exists my_table;
mysql> create table my_table (ID int not null primary key, l_name
    -> varchar(20) not null, f_name varchar(20));
Query OK, 0 rows affected (0.08 sec)

mysql> describe my_table;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| ID     | int(11)     |      | PRI | 0       |       |
| l_name | varchar(20) |      |     |         |       |
| f_name | varchar(20) | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.04 sec)

mysql> insert into my_table values (1,"Frost",'Robert');
Query OK, 1 row affected (0.03 sec)

mysql> insert into my_table (ID,l_name) values (2,'Smith');
Query OK, 1 row affected (0.00 sec)

mysql> select * from my_table;
+----+--------+--------+
| ID | l_name | f_name |
+----+--------+--------+
|  1 | Frost  | Robert |
|  2 | Smith  | NULL   |
+----+--------+--------+
2 rows in set (0.01 sec)

mysql> update my_table set f_name='Linda' where l_name='Smith'
    -> and ID=2;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from my_table;
+----+--------+--------+
| ID | l_name | f_name |
+----+--------+--------+
|  1 | Frost  | Robert |
|  2 | Smith  | Linda  |
+----+--------+--------+
2 rows in set (0.00 sec)

mysql> delete from my_table where ID=1;
mysql> select * from my_table;
+----+--------+--------+
| ID | l_name | f_name |
+----+--------+--------+
|  2 | Smith  | Linda  |
+----+--------+--------+
1 row in set (0.01 sec)

mysql> create table table_name select * from bank.BANK_WORKER;
(copy table bank.BANK_WORKER into table_name)

Comments

Popular posts from this blog

Mongodb online Training course Agenda

  Goal:   In this module, you will get an understanding of NoSQL databases, design goals, requirement of NoSQL database/ MongoDB, MongoDB® architecture and introduction to JSON and BSON among others. This module will also cover the installation of MongoDB® and associated tools. Skills Understand NoSQL databases and  advantages Install MongoDB on Windows and Linux platform Security Enable and high availability Objectives After completing this module, you will  be able knowledge ed on SQL and noSQL Database usages and difference between these MongoDB design and architecture  MongoDB GUI tools Describe JSON and BSON Install MongoDB on Windows, Linux, MAC OS etc.  Setup MongoDB environment Topics • Understanding the basic concepts of a Database • Database categories: What is NoSQL? Why NoSQL? Benefit over RDBMS  • Types of NoSQL Database, and NoSQL vs. SQL Comparison, ACID & Base Property • CAP Theorem, implementing NoSQL and what is MongoDB?  • O...

MySQL Architecture -Client Server Architecture

Client/Server Overview The MySQL database system operates using a client/server architecture. The server is a central program that manages database contents, and client programs connect to the server to retrieve or modify the data. MySQL also includes non-client utility programs and scripts. MySQL Server:   This is the mysqld program that manages database and tables. Most users choose binary MySQL distribution that includes a server ready to run with the capabilities they need, but it's also possible to compile MySQL from source. Client Programs:  These are programs that communicate with the server by sending requests to it over a network connection. The server acts on each request and returns a response to the client. For example you can use the mysql client to send queries to the server, and the server returns the query results. A client program can connect locally to a server running on the same machine or remotely to a server running on a different mac...

Load test Monitor script

 #!/bin/bash # Define logfile and other variables LOGFILE="/path/to/mongod.log"    # Path to MongoDB log file OUTPUT_FILE="/path/to/output.log" # Path where the output will be saved # Record the date echo "===== Date: $(date) =====" >> $OUTPUT_FILE # Record just the first line of w output (system uptime, users, and load average) echo "===== System Uptime, Users, and Load Average (w command) =====" >> $OUTPUT_FILE w | head -n 1 >> $OUTPUT_FILE # Record only the %user value from iostat echo "===== I/O Statistics (%user from iostat command) =====" >> $OUTPUT_FILE iostat | awk '/^ / {getline; print "User CPU: " $1 "%"}' >> $OUTPUT_FILE # Capture top processes, filtering for MongoDB (mongod) echo "===== Top Processes (top command) - Filter for mongod =====" >> $OUTPUT_FILE top -b -n 1 | grep mongod >> $OUTPUT_FILE # Filter MongoDB log for specific information (e....