Get Size of Tables and Database in MySQL

Get size of a specific table in MySQL. SELECT table_name AS `Table_Name`, round(((data_length + index_length) / 1024 / 1024), 2) `Table Size in MB` FROM information_schema.TABLES WHERE table_schema = ‘$DATABASE_NAME’ AND table_name = ‘$TABLE_NAME’; Get size of all tables of a specific schema in MySQL. SELECT table_name AS `Table_Name`, round(((data_length + index_length) / 1024 / … Read more

Kill Processes MySQL

First, execute below command to see all active processes. SHOW PROCESSLIST; Use below command to kill a specific process. Syntax: KILL id; Example KILL 5; Use below command to kill all processes. SELECT CONCAT(‘KILL ‘,id,’;’) FROM information_schema.processlist WHERE user=’root’ INTO OUTFILE ‘/tmp/processlist.txt’; Use below command to kill all processes of a user. kill USER username;

replace all square brackets in a string java regex

public class Main { public static void main(String[] args) { String str = “[This is a] [Test String]”; System.out.println(“String with square brackets: ” + str); str = str.replaceAll(“”,””); System.out.println(“String after square brackets: ” + str); } } Output: String with square brackets: [This is a] [Test String] String after square brackets: This is a Test … Read more

Searching for a specific node in Doubly Linked List

To search for a specific element in the list, traverse the list in order, by following the below steps: Use the below statement, to copy the head pointer into a temporary pointer variable ptr. ptr = headptr = head Use the below statement, to declare a local variable “i” and assign a 0 to it. … Read more

Traversing in doubly linked list

In any type of data structure, traversing is the most common operation. Visiting each node of the list once to perform some specific operation, is called traversing. We will follow the below steps for traversing in a doubly-linked list: Use the below statement, to copy the head pointer in any of the temporary pointer ptr. … Read more

Deletion in the doubly linked list at end

First, we need to traverse the list to reach the last node of the list. Deletion of the last node in a doubly-linked list requires pointer adjustments at that position. We will follow the below steps, to delete the last node of the list: If the condition head == NULL is true, no operation can … Read more

Deletion in doubly linked list after specified node

We will follow the below steps, to delete the node after the specified data: Use the below statement, to copy the head pointer into a temporary pointer temp. temp = headtemp = head Use the below statements, to traverse the list until we find the desired data value. while(temp -> data != val) temp = … Read more

Deletion in doubly linked list at beginning

Being the simplest operation, we just need to copy the head pointer to pointer ptr and shift the head pointer to its next, for deletion in the doubly linked list at the beginning. ptr = head; head = head → next;ptr = head; head = head → next; Now, use the below statements, to make … Read more

Insertion in doubly linked list at the end

We need to ensure if the list is empty or it contains any element, before inserting a node in the doubly linked list at the end. To insert the node in the doubly linked list at the end, we can follow the below steps: Use the below statement to allocate the memory for the new … Read more

Insertion in doubly linked list after the specified node

Before making the required pointer adjustments, skip the required number of nodes to reach the mentioned node, to insert a node after that specified node, in the list. For this, we will use the below steps: Use the below statement to allocate the memory for the new node. ptr = (struct node *)malloc(sizeof(struct node));ptr = … Read more