MySQL Articles

Found 3,543 articles

How to convert Python date format to 10-digit date format for mysql?

Pranav Indukuri
Pranav Indukuri
Updated on 28-Aug-2025 2K+ Views

While working with databases like MySQL, it’s necessary to store dates in a numeric format, especially for timestamps. MySQL commonly uses Unix timestamps, which are 10-digit numbers representing the number of seconds since January 1, 1970 (known as the epoch). The following are the different methods from the time and datetime modules to convert Python date formats into a 10-digit format (Unix timestamp) suitable for use with MySQL. Using mktime() Method Using strptime() + mktime() Combination Using timestamp() Method Using mktime() Method The mktime() method from ...

Read More

Count the number of columns in a MySQL table with Java

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Jul-2025 489 Views

In this article, we will learn how to count the number of columns in a MySQL table using JDBC. We will be using the ResultSetMetaData to get details of the table by using simple examples. What is ResultSetMetaData? The ResultSetMetaData is an interface that is present in the java.sql package. Using ResultSetMetaData, we can get information about the table, for example, what are the column names of each and every table, and how many columns are there?. To create the object for ResultSet: ResultSet rs=st.executeQuery("Select * from Student"); The executeQuery method writes the records, which are then stored in the ...

Read More

How to Connect to Mysql Server Using VS Code and Fix errors?

Priyanka Gupta
Priyanka Gupta
Updated on 17-Mar-2025 509 Views

MySQL is a relational database based on Structured Query Language used to access and manage records in a database. MySQL is based on a client-server architecture that follows a request-response cycle. Clients make requests through GUI or command prompt using MySQL.  Fixing Errors in MySQL Server Here are the steps to connect to the MySQL Server using VS Code - Open Visual Studio code. Go To -> extensions, search MySQL Open the extension called MySQL management tool and install it. Click on the ...

Read More

Decimal vs Double vs Float in MySQL

Thanasekar K
Thanasekar K
Updated on 17-Mar-2025 614 Views

When designing a MySQL database, selecting the right numeric data type is crucial for balancing precision, storage efficiency, and performance. Decimal, Double, and Float are three common numeric types, each serving distinct purposes. While Decimal offers exact precision for financial data, Float and Double handle approximate values for scientific calculations. This article explores their differences, use cases, and practical examples to help you make informed decisions. What is Decimal Decimal (or DECIMAL(M, D)) is a fixed-point data type designed for precise arithmetic, such as financial calculations. It stores exact numeric values with a specified precision (M = total ...

Read More

What is the difference between CHAR and NCHAR in MySQL?

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 19-Feb-2025 907 Views

In MySQL, both CHAR and NCHAR are ASCII character data types used for storing text data, but they differ significantly in terms of storage, data representation, and performance. CHAR and NCHAR columns can have different collations, determining how strings are compared and sorted. The CHAR type typically uses the collation associated with its specified character set. On the other hand, NCHAR is intended for Unicode data and typically uses a collation that can handle Unicode characters, ensuring proper sorting and comparison. Understanding 'CHAR' in MySQL The CHAR data type is primarily used to store ASCII character data. It is a ...

Read More

What MySQL returns if I insert invalid value into ENUM?

Venu Madhavi
Venu Madhavi
Updated on 12-Feb-2025 947 Views

If strict SQL mode is disabled and we insert an invalid value (which is not in the list of permitted enumeration values) into ENUM, MySQL will insert an empty string instead of throwing an error. If strict SQL mode is enabled, MySQL throws an error when inserting invalid value. Invalid values without strict SQL mode Strict SQL mode is disabled by default. When it is disabled, if we enter an invalid value that is not in the ENUM list, it returns an empty string. Let us understand this by using the example below. Example In the below example we have ...

Read More

Use a trigger to stop an insert or update in MySQL?

Venu Madhavi
Venu Madhavi
Updated on 12-Feb-2025 6K+ Views

The MySQL trigger can be used to automatically terminate an INSERT or UPDATE operation if specific conditions are not met. This is achieved by adding logic to the trigger to detect incorrect data or violations of a rule. If the condition is satisfied, the SIGNAL statement is used to show a customized error message and terminate the procedure. Thus, it ensures that the database has valid, clean, and consistent data. For instance, if a value is being updated or inserted in the column beyond the allowed range, the trigger can stop the action and give a customized error message. ...

Read More

What does DELIMITER // do in a Trigger in MySQL?

Venu Madhavi
Venu Madhavi
Updated on 12-Feb-2025 3K+ Views

DELIMITER in MySQL Triggers In MySQL, a DELIMITER command changes the delimiter from its default value of semicolon (;) to another string like //. This is really useful when creating stored procedures or triggers that contain multiple SQL statements, which may also include semicolons. Why do we Change the Delimiter in MySQL When you declare a trigger, you have to write a few SQL statements that may also involve control flow statements like IF conditions, which include semicolons. Unless you change the delimiter, MySQL will consider the first semicolon to be the end of the declaration of the ...

Read More

Why should we not store a number into a MySQL ENUM column?

Venu Madhavi
Venu Madhavi
Updated on 12-Feb-2025 1K+ Views

MySQL stores ENUM values internally as integer keys (index numbers) to reference ENUM members. The main reason for not storing the integer values in the ENUM column is that it is very obvious that MySQL ends up referencing the index instead of the value and vice-versa. These indexes begin at 1, not 0, and map to the order of the values defined during table creation. If a number is inserted directly into an ENUM column, MySQL interprets it as the corresponding index, leading to unexpected behavior. Example Let us create a table named Enmtest ...

Read More

Select records with ACTIVE status in MySQL set with ENUM

Venu Madhavi
Venu Madhavi
Updated on 04-Feb-2025 1K+ Views

MySQL's ENUM data type is used to define a specific set of values in a column making it easier to manage and maintain data consistency. GROUP BY and WHERE() function In MySQL WHERE clause is used to filter the rows based on a condition before grouping them. The GROUP BY clause groups rows with identical values in specified columns, and can be used with functions like SUM, COUNT, and AVG. Together they enable focused data analysis by filtering and grouping efficiently. Syntax Following is the syntax to filter the data on certain conditions and to eliminate duplicate records. SELECT column1, ...

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