Rama Giri

Rama Giri

87 Articles Published

Articles by Rama Giri

Page 3 of 9

How can we add multiple columns, with single command, to an existing MySQL table?

Rama Giri
Rama Giri
Updated on 20-Jun-2020 8K+ Views

We can also add multiple columns to an existing table with the help of ALTER command. The syntax for it would be as follows −SyntaxAlter table table-name ADD (column-name1 datatype, column-name2 datatype,… column-nameN datatype);ExampleIn the example below, with the help of ALTER Command, columns ‘Address’, ‘Phone’ and ‘Email’ are added to the table ‘Student’.mysql> Alter Table Student ADD(Address Varchar(25), Phone INT, Email Varchar(20)); Query OK, 5 rows affected (0.38 sec) Records: 5 Duplicates: 0 Warnings: 0

Read More

How can we emulate CHECK CONSTRAINT by using triggers?

Rama Giri
Rama Giri
Updated on 19-Jun-2020 298 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 ‘car’ which can have the fix syntax registration number like two letters, a dash, three digits, a dash, two letters as follows −mysql> Create table car (number char(9)); Query OK, 0 rows affected (0.32 sec) mysql> Insert into car values('AB-235-YZ'); Query OK, 1 row affected (0.10 sec)The above value is a valid one but what ...

Read More

How to disable MySQL foreign key checks and what are the benefits of\\ndisabling it?

Rama Giri
Rama Giri
Updated on 19-Jun-2020 350 Views

We can disable foreign key checks with the help of the following statement −mysql> Set foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec)And we can enable it with the help of the following statement −mysql> Set foreign_key_checks = 1; Query OK, 0 rows affected (0.00 sec)Some benefits of disabling foreign key checks are as follows −After disabling foreign key checks we can load data into parent and child table in any order. Otherwise, we must have to load the data first in the parent table and then in the child table.Without disabling foreign key checks we cannot drop ...

Read More

How is the java memory pool divided?

Rama Giri
Rama Giri
Updated on 18-Jun-2020 472 Views

Java memory pool is divided into 5 parts namely −Method area − The method area stores the class code − code of the variables and methods.Heap−The Java objects are created in this area.Java Stack− While running methods the results are stored in the stack memory.PC registers− These contain the address of the instructions of the methods.Native method stacks− Similar to Java stack, native methods are executed on the Native method stacks.

Read More

How to return a random number between 0 and 199 with JavaScript?

Rama Giri
Rama Giri
Updated on 20-May-2020 440 Views

To return a random number between 0 and 199, use the JavaScript Math.random() and Math.floor() method.ExampleYou can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200));          

Read More

Removal of negative numbers from an array in Java

Rama Giri
Rama Giri
Updated on 24-Feb-2020 845 Views

Following program shows how to remove negative numbers from an array.Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Tester {    public static void main(String[] args) {       List objArray = new ArrayList();       objArray.clear();       objArray.add(2);       objArray.add(-3);       objArray.add(4);       System.out.println("Array before removing an element "+objArray);       Iterator iterator = objArray.iterator();                while(iterator.hasNext()) {          Integer next = iterator.next();          if(next < 0) {             iterator.remove();          }       }       System.out.println("Array after removing an element"+objArray);    } }OutputArray before removing an element [ 2, -3, 4 ] Array after removing an element [ 2, 4 ]

Read More

What happens if the substring is there for more than one time in the string given as the arguments of LOCATE() function?

Rama Giri
Rama Giri
Updated on 03-Feb-2020 146 Views

In case if the substring is there for more than one time in the string then MySQL LOCATE() function will return the position of the first occurrence of the substring.Examplemysql> Select LOCATE('good','Ram is a good boy. Is Ram a good boy?')As Result; +--------+ | Result | +--------+ |     10 | +--------+ 1 row in set (0.00 sec)As we can see that the substring ‘good’ is in the string for two times. The first occurrence is at position 10 and another occurrence is at position 29. MySQL returns the position of the first occurrence.

Read More

How can we update values in a MySQL table?

Rama Giri
Rama Giri
Updated on 30-Jan-2020 607 Views

With the help of UPDATE statement and WHERE clause, we can update the values in single or multiple rows of the table. MySQL updates the values on the basis of condition specified in WHERE clause. For example, suppose in the ‘employee’ table we want to change the ‘name’ and ‘doj’ of the employee whose id is 1 then it can be done with the following query −mysql> UPDATE employee SET name = 'Gaurav', doj = '2010-02-01' WHERE id = 1; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from employee ...

Read More

Is there a naming convention for tables in MySQL?

Rama Giri
Rama Giri
Updated on 28-Jan-2020 593 Views

No, MySQL does not have a preferred naming convention standard. If the name we have chosen is logical and consistent then it would be ok.Two major points need to be remembered, one is that no two tales/databases can have the same name and second we can choose any of the reserved words as the name of table/database.

Read More

Adding a condition using SQL or an ABAP program and difference in performance

Rama Giri
Rama Giri
Updated on 28-Jan-2020 320 Views

As there are just 500, there would not be much difference among both options. You can use either of them.The ABAP code is as below −LOOP AT lt_table TRANSPORTING NO FIELDS WHERE exp > 5    ADD 1 TO lt_counter ENDLOOP

Read More
Showing 21–30 of 87 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements