- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4378 Articles for MySQL
103 Views
It can be illustrated with the help of an example in which we are creating a virtual generated column in the table named ‘triangle’. As we know that virtual generated column can be generated with or without using the keyword ‘virtual’.Examplemysql> Create table triangle(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB))); Query OK, 0 rows affected (0.44 sec) mysql> Describe Triangle; +-------+--------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+-------------------+ | SideA | double | YES | | ... Read More
203 Views
It can be illustrated with the help of an example in which we are creating a virtual generated column in the table named ‘employee_data’. As we know that virtual generated column can be generated with or without using the keyword ‘virtual’.Examplemysql> Create table employee_data(ID INT AUTO_INCREMENT PRIMARY KEY, First_name VARCHAR(50) NOT NULL, Last_name VARCHAR(50) NOT NULL, FULL_NAME VARCHAR(90) GENERATED ALWAYS AS(CONCAT(First_name, '', Last_name))); Query OK, 0 rows affected (0.55 sec) mysql> DESCRIBE employee_data; +------------+-------------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra ... Read More
79 Views
We have two types of MYSQL generated columns as follows −VIRTUAL GENERATED COLUMNAs the name suggests, this kind of generated column will not take any disk space. It can be generated with or without using the keyword ‘virtual’. To understand we are illustrating it in the following example −Examplemysql> Create table triangle(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB))); Query OK, 0 rows affected (0.44 sec) mysql> Describe Triangle; +-------+--------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+-------------------+ | SideA ... Read More
1K+ Views
Basically generated columns are a feature that can be used in CREATE TABLE or ALTER TABLE statements and is a way of storing the data without actually sending it through the INSERT or UPDATE clause in SQL. This feature has been added in MySQL 5.7. A generated column works within the table domain. Its syntax would be as follows −Syntaxcolumn_name data_type [GENERATED ALWAYS] AS (expression) [VIRTUAL | STORED] [UNIQUE [KEY]]Here, first of all, specify the column name and its data type.Then add the GENERATED ALWAYS clause to indicate that the column is a generated column.Then, indicate whether the type of ... Read More
161 Views
PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. This function basically returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Return of an integer > 0 indicates the number of rows affected, 0 indicates that no records were affected and -1 indicates that the query returned an error. Its syntax is as follows −Syntaxmysql_affected_rows( connection );Followings are the parameters used in this function −S. No.Parameter & Description1.ConnectionRequired – Specifies the MySQL connection to use
1K+ Views
MySQL UNION operator can combine two or more result sets hence we can use UNION operator to create a view having data from multiple tables. To understand this concept we are using the base tables ‘Student_info’ and ‘Student_detail’ having the following data −mysql> Select * from Student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla | Computers | | 130 | Ram ... Read More
1K+ Views
As we know that PHP provides us the function named mysql_query() to create a MySQL table. Similarly, we can use mysql_query() function to create MySQL temporary table. To illustrate this, we are using the following example −ExampleIn this example, we are creating a temporary table named ‘SalesSummary’ with the help of PHP script in the following example − Creating MySQL Temporary Tables
63 Views
As we know that MySQL supports foreign key for referential integrity but it does not support CHECK constraint. But we can emulate them by using triggers. It can be illustrated with the help of an example given below −ExampleSuppose we have a table named ‘car1’ which can have the fix syntax registration number like two letters, a dash, three digits, a dash, two letters as follows −mysql> Create table car1 (number char(9)); Query OK, 0 rows affected (0.32 sec) mysql> Insert into car1 values('AB-235-YZ'); Query OK, 1 row affected (0.10 sec)The above value is a valid one but what ... Read More