UNIQUE Constraint

UNIQUE Constraint The UNIQUE constraint ensures that all values in a column are different. Both the UNIQUE and PRIMARY KEY constraints provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint. However, you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table. This constraint ensures that all values inserted into the column … Read more

MySQL – NOT NULL Constraint

NOT NULL Constraint By default, a column can hold NULL values. The “NOT NULL constraint” enforces a column to NOT accept NULL values. This enforces a field to always contain a value, which means that you cannot insert a new record, or update a record without adding a value to this field. This constraint specifies that … Read more

MySQL Constraints

MySQL Constraints SQL constraints are used to specify rules for data in a table. The constraint in MySQL is used to specify the rule that allows or restricts what values or data will be stored in the table. They provide a suitable method to ensure data accuracy and integrity inside the table. It also helps … Read more

MySQL CREATE TABLE Statement

MySQL CREATE TABLE Statement The MySQL CREATE TABLE Statement The CREATE TABLE statement is used to create a new table in a database. Syntax CREATE TABLE table_name (     column1 datatype,     column2 datatype,     column3 datatype, …. ); The column parameters specify the names of the columns of the table. The datatype parameter specifies the type of data the … Read more

MySQL AUTO INCREMENT Field

MySQL AUTO INCREMENT Field What is an AUTO INCREMENT Field? Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted. MySQL AUTO_INCREMENT Keyword MySQL uses … Read more

Install MySQL / MariaDB Server with PhpMyAdmin Centos 8

Install MySQL / MariaDB Server with PhpMyAdmin Centos 8 Install PHP, MySQL support package for PHP, and other PHP packages on your system for phpMyAdmin to connect with the database. dnf install -y wget php php-pdo php-pecl-zip php-json php-common php-fpm php-mbstring php-cli php-mysqlnd php-xml tar Install below PHP packages for phpMyAdmin to connect with the … Read more

mysql is dead but subsys locked

mysql 5.7

MySQL is dead but subsys locked Issue Description: When tried to connect to MySQL or run any command. It Displayed The Following Error: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock'(2) When checked the status of MySQL service from the below command: service mysqld status as a root user I got : mysql is dead … Read more

How to check table Engine in MySQL

How to check table Engine in MySQL With the help of below query, we can check the table engine in MySQL: SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = ‘nicesys’; Please change the db name to your DB name. You will get the output like : | TABLE_NAME | ENGINE | +——————–+——–+ | cdr | … Read more

MySQL Addtime() : Adding time to datetime

MySQL Addtime() : Adding time to datetime The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime. Syntax ADDTIME(datetime, addtime) Parameter Values Parameter Description datetime Required.  The time/datetime to be modified addtime Required. The time interval to add to datetime. Both positive and negative values are allowed Example: SELECT ADDTIME(“2021-06-03 09:34:21”, “2”); Output: … Read more

Data Manipulation Language in SQL (DML)

SQL language also includes syntax to update, insert, and delete records. These query and update commands together form the Data Manipulation Language (DML) part of SQL: • INSERT INTO – inserts new data into a database table • UPDATE – updates data in a database table • DELETE – deletes data from a database table … Read more