Database Articles

Page 166 of 546

While creating a MySQL table, how can I specify the storage engine of my choice rather than using the default storage engine InnoDB?

Ramu Prasad
Ramu Prasad
Updated on 20-Jun-2020 156 Views

While creating a MySQL table, the storage engine can be specified as follows −mysql> CREATE TABLE Student(id INTEGER PRIMARY KEY, Name VARCHAR(15)) -> ENGINE = 'MyISAM'; Query OK, 0 rows affected (0.28 sec)The ENGINE keyword specifies the storage engine used for this particular table.

Read More

How MySQL evaluates if I try to add two numbers that are contained in quotes?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 20-Jun-2020 144 Views

If we are trying to add two numbers that are contained in quotes, means we are treating the string as a number. In this case, MySQL converts the value into the closet numeric equivalent and evaluates the result. Following example will demonstrate it.Examplemysql> Select '1525' + '200'As Total; +-------+ | Total | +-------+ | 1725  | +-------+ 1 row in set (0.00 sec)

Read More

How can column data be used within MySQL CASE statement?

Rishi Raj
Rishi Raj
Updated on 20-Jun-2020 222 Views

To understand it consider the data, as follows, from the table ‘Students’ −mysql> Select * from Students; +----+-----------+-----------+----------+----------------+ | id | Name      | Country   | Language | Course         | +----+-----------+-----------+----------+----------------+ | 1  | Francis   | UK        | English  | Literature     | | 2  | Rick      | USA       | English  | History        | | 3  | Correy    | USA       | English  | Computers      | | 4  | Shane     | France    | ...

Read More

How can we establish MySQL database by using MySQL binary at command\\nprompt?

Sravani S
Sravani S
Updated on 20-Jun-2020 153 Views

You can establish the MySQL database using the mysql binary at the command prompt. It can be understood with the help of the following example −ExampleWe can use following statements to connect to the MySQL server from the command prompt −[root@host]# mysql -u root -p Enter password:******This will give us the mysql> command prompt where we will be able to execute any SQL command. Following is the result of above command −The following code block shows the result of above code −Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20 MySQL ...

Read More

How can we distinguish between MySQL IFNULL() and NULLIF() functions?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 3K+ Views

Actually, both MySQL IFNULL() and NULLIF() functions are having an almost same syntax as given below −The syntax of IFNULL()IFNULL(expression1, expression2)The syntax of NULLIF()NULLIF(expression1, expression2)They can be distinguished in the way they return the first argument as result. IFNULL() function will return the first argument as a result if it is not NULL and NULLIF() function will return the first argument as a result if both the arguments are not same.mysql> Select IFNULL('Ram', 'Shyam'); +-----------------------+ | IFNULL('Ram', 'Shyam') | +-----------------------+ | Ram                   | +-----------------------+ 1 row in set (0.00 sec) mysql> Select ...

Read More

In MySQL, without having BOOLEAN data type how can we show TRUE and FALSE values?

Sharon Christine
Sharon Christine
Updated on 20-Jun-2020 247 Views

As we know that there is no BOOLEAN data type in MySQL hence by using TRUE or true, FALSE or false we can enter Boolean values in MySQL statement.Examplemysql> Select TRUE,FALSE; +------+-------+ | TRUE | FALSE | +------+-------+ |    1 |     0 | +------+-------+ 1 row in set (0.00 sec) mysql> Select true,false; +------+-------+ | TRUE | FALSE | +------+-------+ |    1 |     0 | +------+-------+ 1 row in set (0.00 sec)

Read More

How does MySQL IF() function work?

Ankith Reddy
Ankith Reddy
Updated on 20-Jun-2020 193 Views

MySQL IF() function is one of the MySQL control flow functions that returns a value based on a condition. It is sometimes referred to as IF ELSE or IF THEN ELSE function. Basically, it takes three expressions and if the first expression is true (not ZERO and not NULL), it returns the second expression. Otherwise, it returns the third expression. Its syntax is as follows −SyntaxIF(expr, value_if_true, value_if_false)Here expr is the expression having some condition.Value_if_true is the value to return if expr evaluates to TRUE.Value_if_false is the value to return if expr evaluates to FALSE.Examplemysql> Select IF(100=100, 'YES', 'NO'); +------------------------+ | ...

Read More

How can we update MySQL table after removing a particular string from the values of column?

Arjun Thakur
Arjun Thakur
Updated on 20-Jun-2020 582 Views

We can update MySQL table after removing a particular string from the values of a column by using TRIM() function along with UPDATE clause. Following the example from ‘examination_btech’ table will make it clearer −ExampleSuppose if we want to delete the values ‘(CSE)’, from last, of column ‘Course’ and want to update the table too then it can be done with the help of the following query −mysql> Update examination_btech SET Course = TRIM(Trailing '(CSE)' FROM Course); Query OK, 10 rows affected (0.13 sec) mysql> Select * from examination_btech; +-----------+----------+--------+ | RollNo    | Name     | Course | +-----------+----------+--------+ | 201712001 | Rahul ...

Read More

How can I get the list of columns from a table in the other database than we are currently using?

varun
varun
Updated on 20-Jun-2020 134 Views

It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows −SyntaxSHOW COLUMNS FROM db_name.tab_nameHere, tab_name is the name of the table from which we want to see the list of columns.Db_name is the name of the database, in which the table is storedExampleIn the example we are currently using the database ‘query’ and getting the list of columns from table named ‘arena’ stored in mysql ‘database’ −mysql> SHOW COLUMNS FROM mysql.arena\G *************************** 1. row ***************************   Field: id    Type: int(10) unsigned zerofill    Null: NO     Key: PRI Default: NULL   Extra: auto_increment ...

Read More

How can we set up a MySQL User account by using INSERT INTO statement?

V Jyothi
V Jyothi
Updated on 20-Jun-2020 2K+ Views

For adding a new user to MySQL, we just need to add a new entry to the user table in the database mysql. To illustrate it we are using the following example −ExampleThe following program is an example of adding a new user guest with SELECT, INSERT and UPDATE privileges with the password guest123; the SQL query is −root@host# mysql -u root -p Enter password:******* mysql> use mysql; Database changed mysql> INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'guest', PASSWORD('guest123'), 'Y', 'Y’, 'Y'); Query OK, 1 row affected (0.20 sec) mysql> FLUSH PRIVILEGES; Query OK, ...

Read More
Showing 1651–1660 of 5,457 articles
« Prev 1 164 165 166 167 168 546 Next »
Advertisements