MySQL Articles

Page 4 of 355

How can I remove a value from an enum in MySQL?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 2K+ Views

Removing Value from an enum in MySQL We can use the ALTER command to remove a value from an ENUM in MySQL. The ALTER database command lets you modify the type of a column, add or remove columns, or even modify ENUM values in a current database. You cannot delete a value from an ENUM type. To accomplish that task, you change the column definition - by changing the list of allowed values. This way, the structure of the table is not changed while the set of possible values for the ENUM column is changed. Example Let us first create ...

Read More

How can I insert default value in MySQL ENUM data type?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 4K+ Views

When designing a database, setting default values for certain fields will improve data integrity. In MySQL, ENUM data type allows you to specify predefined values for a column such as status (complete or incomplete). This article helps you to set a default value for ENUM columns, to ensure that even if the data is missing, a suitable value is automatically assigned. Inserting a default value with ENUM data type We can do this with the help of the DEFAULT attribute of the ENUM data type. The DEFAULT attribute causes an ENUM data type to have a default value when a ...

Read More

Count items in a MySQL table with type ENUM involved?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 1K+ Views

Counting ENUM items in MySQL In MySQL, ENUM is a data type where it stores the predefined and fixed values making them ideal for categories such as sizes, grades, and statuses. Knowing the frequency of each value inside ENUM columns will allow you to make data-driven decisions. Below, we'll learn how to use MySQL's GROUP BY and COUNT() functions to get the count of ENUM values. GROUP BY(): It is used for aggregating data, as it follows you to perform calculations, such as totals, and averages. ...

Read More

How can we create multiple MySQL triggers for the same trigger event and action time?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 932 Views

In MySQL, a trigger is a group of SQL statements performed or fired when a specified event is taken place on tables. The events can include INSERT, UPDATE, and DELETE. Such triggers are used for automating repetitive work, ensuring integrity in data, and keeping audit records without human involvement. The FOLLOWS keyword in MySQL allows the creation of several triggers for the same event and also allows you to select the order of execution. Creating Multiple Triggers for the Same Event When working with triggers, sometimes you might need to define several triggers for the same ...

Read More

Add a new value to a column of data type enum in MySQL?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 26K+ Views

In MySQL, the ENUM is a data type that is used to create a column with a fixed set of values. It is helpful for the fields that have limited alternatives, such as categories, statuses, and color codes. However, as your application evolves, you might need to add more values to the list such as new colors. MySQL allows us to modify ENUM values without dropping and recreating the column. Adding New Value to an ENUM column For adding new values in an ENUM column in MySQL, you shall use the ALTER TABLE command with the MODIFY Keyword. For ...

Read More

Show MySQL host via SQL Command?

George John
George John
Updated on 24-Dec-2024 31K+ Views

To display MySQL host via SQL command, use the system variable hostname. Query 1 The following is the query to display the host − mysql > select @@hostname; Output Here is the output − +-----------------+ | @@hostname | +-----------------+ | DESKTOP-QN2RB3H | +-----------------+ 1 row in set (0.00 sec) Query 2 Or you can use "show variables" command to show MySQL host via SQL command. show variables where Variable_name like '%host%'; Output The following is the output − +-------------------------------+-----------------+ | Variable_name | Value | +-------------------------------+-----------------+ | host_cache_size | 279 | | hostname  | DESKTOP-QN2RB3H | | performance_schema_hosts_size | -1 | | report_host | | +-------------------------------+-----------------+ 4 rows in set (0.07 sec)

Read More

Difference between Static SQL and Dynamic SQL

Mahesh Parahar
Mahesh Parahar
Updated on 23-Dec-2024 28K+ Views

Static SQLStatic SQL refers to those SQL statements which are fixed and can be hard coded into the application. As static sqls are fixed queries, these statements can be analyzed and optimized and do not require any specific handling for security purposes.Dynamic SQLDynamic SQL refers to those SQL statements which are generated dynamically based on user's input and run in the application. Dynamic Sqls helps to develop general and flexible applications. Dynamic SQL may need more permissions and security handling and a malicious user can create dangerous code as well.Following are some of the important differences between Static Routing and ...

Read More

Java – MySQL connection with ipAddress

AmitDiwan
AmitDiwan
Updated on 08-Nov-2024 1K+ Views

In this article, we will learn how to connect a Java application to a MySQL database hosted on a specific IP address. By specifying the IP address in the connection URL, we can directly connect to the database even if it’s on a different machine. We’ll use the DriverManager.getConnection() method to initiate the connection. Steps to connect a MySQL database via IP Address Following are the steps to connect a MySQL database via IP Address − Import Connection and DriverManager classes from the java.sql package to enable database connectivity. Create a String ...

Read More

10 Advance MySQL Database Interview Questions and Answers

Satish Kumar
Satish Kumar
Updated on 06-Nov-2024 955 Views

Introduction MySQL is one of the most widely used open-source relational database management systems (RDBMS) in world. It is used by some of the largest companies in the world, including Google, Facebook, and Twitter. If you are preparing for an interview for a MySQL developer position, you need to be well-prepared with advance MySQL database interview questions and answers. In this article, we will cover some of the most common and advanced MySQL database interview questions and provide you with the best possible answers. What is MySQL? MySQL is an open-source relational database management system. It is widely used by ...

Read More

10 Basic MySQL Interview Questions for Database Administrators

Satish Kumar
Satish Kumar
Updated on 06-Nov-2024 749 Views

As a database administrator, you need to be well-versed in MySQL, one of the most popular open-source database management systems. Whether you are a beginner or an experienced professional, there are some basic MySQL interview questions that you should be prepared to answer. In this article, we'll cover some of the most common questions and provide examples to help you prepare for your next interview. What is MySQL? MySQL is an open-source relational database management system (RDBMS) that uses SQL (Structured Query Language) to manage and manipulate data. It was first released in 1995 and is currently owned by Oracle ...

Read More
Showing 31–40 of 3,543 articles
« Prev 1 2 3 4 5 6 355 Next »
Advertisements