Found 6705 Articles for Database

How MySQL stored GENERATED COLUMNS can work with mathematical expressions?

Samual Sam
Updated on 21-Feb-2020 12:20:32

153 Views

It can be illustrated with the help of an example in which we are creating a stored generated column in the table named ‘triangle_stored’. As we know that stored generated column can be generated by using the keyword ‘stored’.Examplemysql> Create table triangle_stored(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB)) STORED); Query OK, 0 rows affected (0.47 sec) mysql> Describe triangle_stored; +-------+--------+------+-----+---------+------------------+ | Field | Type   | Null | Key | Default | Extra            | +-------+--------+------+-----+---------+------------------+ | SideA | double | YES  |     | NULL   ... Read More

How MySQL virtual GENERATED COLUMNS can work with mathematical expressions?

Ankith Reddy
Updated on 21-Feb-2020 11:39:55

165 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

How Can MySQL virtual GENERATED COLUMNS work with built-in functions?

Ayyan
Updated on 21-Feb-2020 11:39:09

280 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

What are the different types of MySQL GENERATED COLUMNS?

Kumar Varma
Updated on 22-Jun-2020 14:29:07

154 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

What is MySQL GENERATED COLUMN and how to use it while creating a table?

Lakshmi Srinivas
Updated on 22-Jun-2020 14:30:09

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

How can we write PHP script to get the list of MySQL database?

Priya Pallavi
Updated on 22-Jun-2020 14:31:14

2K+ Views

We can write the following PHP script to get the list of available MySQL databases −Example

How can we write PHP script to count the affected rows by MySQL query?

vanithasree
Updated on 22-Jun-2020 14:30:45

393 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. To illustrate it we are having the following example −Example           Rows affected by query                  

Which PHP function is used to give the number of rows affected by MySQL query?

Nikitha N
Updated on 22-Jun-2020 14:08:04

223 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

How can we create a MySQL view by using data from multiple tables?

Sharon Christine
Updated on 04-Mar-2020 06:29:22

2K+ 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

How can we create a MySQL temporary table by using PHP script?

radhakrishna
Updated on 22-Jun-2020 14:08:57

2K+ 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              

Advertisements