Posts by Devsheet

Read all articles posted by Devsheet programmers and content writers.

Add a Boolean column in MySQL table with default value

Adding a Boolean column in MySQL with a default value is a simple process that can be completed in a few steps. You can add the column to the existing table or while creating a new table. We will explain all the processes that can be used to add the boolean column in the MYSQL table with a default value - true or false.

MySQL Query to change column type

If you want to change the data type of a column in a MySQL table, you need to use the ALTER TABLE statement. To do this, you need to specify the name of the table, the name of the column, and the new data type for that column. For example, if you want to change the data type of the column username to VARCHAR(255), you would use the following statement:

Get table information in MySQL

The SQL Query examples explained in this post can be used to get the information of a Table created in the MySQL database.

Show all column names of a table MySql query

There are a lot of ways to get all the column names of a table in MySql. The simplest one is using DESCRIBE of Mysql and place table name after that.

Apply JOIN on multiple columns of the tables MySql

You can easily apply multiple JOIN conditions while joining two tables. You can use OR operator or AND operator for this purpose.

Select second highest column value MySQL

You can find the second-highest value from a table column in MYSQL by ordering the column values in descending order and using LIMIT and OFFSET.

Order by Date where date in string format MySQL

STR_TO_DATE() function can be used to convert a string in Date format in Mysql. If you want to get results to order by date where the date is in string format, you can use this function.

Delete a column from Table MySQL

You can remove a column from a table using the DROP COLUMN statement in MySQL/SQL

Add comment in Sql or Mysql

For single-line comment use '--' and t comment a full block use /**/

Remove or drop table MySQL

Here we are showing how you can remove a table from the database.

Rename table MySQL

RENAME TABLE statement is used to change that the name of a single table or multiple tables.

Add unique constraint MySQL

UNIQUE constraint on a column ensures that no duplicate field value will be inserted into that column

Show all tables in a database MySQL

To list all tables exists inside a database using the below query in MySQL

Show all Databases MySQL

To list all database in MySQL we use the query - SHOW DATABASES

Create and select database MySQL

CREATE DATABASE query is used to create a new database in MySQL and to use an existing database in MySQL 'USE database_name;' query is used.

In Operator MySQL

Using IN operator you can check whether column values exist in a list of values or in records of a subquery.

Get duplicate rows and its counts MySQL

Duplicate rows in a MySQL database table can cause data inconsistencies and negatively affect the performance of your application. In order to identify and address these duplicates, you can use SQL queries to get a count of duplicate rows in a table.

Add columns, alter table SQL query

An SQL query is a query that is used to alter a table. This query is used to add columns to a table, alter the data type of a column, or to change the name of a column.

Insert data into table mysql query

When working with databases, it is often necessary to insert data into a table. This can be done using the INSERT INTO SQL query. The INSERT INTO query is used to insert data into a table in a database. The data that is inserted into the table is specified in the VALUES clause of the query.

Create table with constraints MySQL query

In MySQL, a constraint is a rule that must be followed by data in a database table. Constraints are used to limit the type of data that can be stored in a column, to ensure data integrity, and to enforce business rules on the data.

Loading more...
Search all posts...