Database Articles

Page 542 of 546

Best data type for storing currency values in a MySQL database?

George John
George John
Updated on 30-Jul-2019 887 Views

For representation of money, we need to use Decimal (TotalDigitsinteger, DigitsAfterDecimalinteger) method. Let’s say, we need to display the value 345.66. For that, count how many digits are available. In value 345.66, there are 5 digits in total and 2 digits after decimal point, which is 66. We can represent the same with the help of Decimal() method from MySQL. Here is the exact representation. DECIMAL(5, 2) Let us first create a table and consider the same above representation for our example − mysql> create table MoneyRepresentation -> ( -> Money ...

Read More

ALTER TABLE to add a composite primary key in MySQL?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

To add composite primary key, use the ALTER command. Let us first create a demo table The query to create a table. mysql> create table CompositePrimaryKey -> ( -> Id int, -> StudentName varchar(100), -> Age int -> ); Query OK, 0 rows affected (0.56 sec) Haven’t added composite primary key above till now. Let us now check with the help of desc command. mysql> desc CompositePrimaryKey; The following is the output. +-------------+--------------+------+-----+---------+-------+ | Field ...

Read More

Alter a MySQL column to be AUTO_INCREMENT?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 3K+ Views

Let’s say we have a table and now there is a requirement to add AUTO_INCREMENT on column name. For that, use the MODIFY command. Here, we will create a demo table first. mysql> create table AddingAutoIncrement -> ( -> Id int, -> Name varchar(200), -> Primary key(Id) -> ); Query OK, 0 rows affected (0.47 sec) We have created a table above and now let us alter the table to add AUTO_INCREMENT on column name ‘Id’. The syntax is as follows − ...

Read More

How can I return 0 for NULL in MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 19K+ Views

We can return 0 for NULL in MySQL with the help of IFNULL() method. The syntax of IFNULL() is as follows. IFNULL(YOUREXPRESSION, 0); Let us see an example. First, we will create a table. mysql> create table NullDemoWithZero -> ( -> id varchar(200) -> ); Query OK, 0 rows affected (0.65 sec) After creating a table, let us insert some records in the table using the INSERT command. The query is as follows − mysql> insert into NullDemoWithZero values(); Query OK, 1 row affected (0.16 sec) ...

Read More

How to get a list of MySQL user accounts?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 225 Views

To get the list of MySQL user accounts, we can use “SELECT USER”. The following is the query to display the list. SELECT User FROM mysql.user; Here is the output. +------------------+ | User | +------------------+ | John | | Mac | | Manish | | mysql.infoschema | | mysql.session ...

Read More

MySQL's DESCRIBE command?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 9K+ Views

The MySQL’s DESCRIBE or DESC both are equivalent. The DESC is the short form of DESCRIBE command and used to dipslay the information about a table like column names and constraints on column name. The DESCRIBE command is equivalent to the following command − SHOW columns from yourTableName command. The following is the query that display information about a table with the help of DESCRIBE command. The query is as follows. mysql> DESCRIBE Student; Above, Student is the table name in my database. The above query generates the following output. +-------+--------------+------+-----+---------+-------+ | Field | Type ...

Read More

What is the benefit of zerofill in MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 2K+ Views

ZEROFILL pads the displayed value of the field with zeros up to the display width set in the column definition. Let us understand the role of zero fill in MySQL using an example. Creating a table with two columns, one has zerofill and the second one does not. The query to create a table. mysql> create table ZeroFillDemo -> ( -> First int(18) zerofill, -> Second int(18) -> ); Query OK, 0 rows affected (0.63 sec) We can insert records in the table with the help ...

Read More

How to get the size of the tables of a MySQL database?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 458 Views

To get the size of the tables of a MySQL database, you can use the “information_schema.tables”. Here is the syntax to know the size of all tables. SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` FROM information_schema.TABLES WHERE TABLE_SCHEMA = "yourDatabaseName" ORDER BY (DATA_LENGTH + INDEX_LENGTH) ASC; Let us apply the above syntax to get the size of the tables. mysql> SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` -> FROM information_schema.TABLES WHERE TABLE_SCHEMA = "business" ...

Read More

SQL Operation supported in SAP HANA SPS06 SDA

John SAP
John SAP
Updated on 30-Jul-2019 259 Views

With use of SAP HANA SPS06 Smart Data Access, you can only perform SELECT operation on virtual tables moved using new remote data source.

Read More

SQL Operation supported in SAP HANA SPS07 SDA

John SAP
John SAP
Updated on 30-Jul-2019 243 Views

With use of SAP HANA SPS06 Smart Data Access, you can only perform Select, Insert, Update and Delete operation on virtual tables moved using new remote data source.

Read More
Showing 5411–5420 of 5,457 articles
« Prev 1 540 541 542 543 544 546 Next »
Advertisements