Prabhas

Prabhas

52 Articles Published

Articles by Prabhas

Page 4 of 6

How to declare, define and call a method in Java?

Prabhas
Prabhas
Updated on 11-Mar-2026 2K+ Views

Following is the syntax to declare a method in Java. Syntax modifier return_type method_name(parameters_list){ //method body } Where, modifier − It defines the access type of the method and it is optional to use. return_type − Method may return a value. method_name − This is the method name. The method signature consists of the method name and the parameter list. parameters_list − The list of parameters, it is the type, order, and a number of parameters of a method. These are optional, method may contain zero parameters. method body − The method body defines ...

Read More

How can we get the total number of rows affected by MySQL query?

Prabhas
Prabhas
Updated on 22-Jun-2020 4K+ Views

MySQL ROW_COUNT() can be used to get the total number of rows affected by MySQL query. To illustrate it we are creating a procedure with the help of which we can insert records in a table and it will show us how many rows have been affected.Examplemysql> Delimiter // mysql> CREATE PROCEDURE `query`.`row_cnt` (IN command VarChar(60000))     -> BEGIN     ->    SET @query = command;     ->    PREPARE stmt FROM @query;     ->    EXECUTE stmt;     ->    SELECT ROW_COUNT() AS 'Affected rows';     -> END // Query OK, 0 rows ...

Read More

How can we discard a MySQL statement in the middle of its processing?

Prabhas
Prabhas
Updated on 22-Jun-2020 149 Views

With the help of \c command, we can discard a MySQL statement in the middle of its processing. Consider the following example in which in the middle of the statement we want to discard it then we use \c option for it −mysql> Select *    -> from\c mysql>The above query shows that after using \c option MySQL discards the statement and returns to the prompt.

Read More

In MySQL, how it can be possible to specify a sort order using a column that is not retrieved by the query?

Prabhas
Prabhas
Updated on 22-Jun-2020 146 Views

Actually, as we know that we can specify a sort order with the help of the ORDER BY clause. We need to write the ORDER BY keyword followed by the name of the column on which we want to sort the table. It is not necessary that we have to use that column name after the SELECT keyword in the query.Examplemysql> Select Sr, Item from ratelist ORDER BY Price; +----+------+ | Sr | Item | +----+------+ |  5 | T    | |  1 | A    | |  2 | B    | |  4 | h    | ...

Read More

How can we alter a MySQL stored procedure?

Prabhas
Prabhas
Updated on 22-Jun-2020 985 Views

If we have ALTER ROUTINE privileges for the procedure then with the help of ALTER PROCEDURE statement we can alter a MySQL stored procedure. To demonstrate it we are taking an example of a stored procedure named ‘delete_studentinfo’ which have the following create a statement −mysql> SHOW CREATE PROCEDURE Delete_studentinfo\G *************************** 1. row *************************** Procedure: Delete_studentinfo sql_mode: ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `Delete_studentinfo`( IN p_id ...

Read More

How can I create a stored procedure to update values in a MySQL table?

Prabhas
Prabhas
Updated on 22-Jun-2020 9K+ Views

We can create a stored procedure with IN operator to update values in a MySQL table. To make it understand we are taking an example of a table named ‘student_info’ having the following data −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Jaipur     | Literature | | 110  | Rahul   | Chandigarh | History    | | 125  | Raman   | Bangalore  | Computers  | +------+---------+------------+------------+ 4 rows ...

Read More

Do we require any authentication for login into MySQL command line tool?

Prabhas
Prabhas
Updated on 20-Jun-2020 193 Views

Yes, we require authentication for login into MySQL command line tool. For example, if we are trying to log in from windows command line then it will prompt for the password every time. The command for login is as follows −C:\Program Files\MySQL\bin>mysql -u root -p Enter password: *****

Read More

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

Prabhas
Prabhas
Updated on 20-Jun-2020 172 Views

It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows −SyntaxSHOW COLUMNS FROM tab_nameHere tab_name is the name of the table from which we want to see the list of columns.ExampleIn the example we are getting the list of columns from a table named Student_info −mysql> SHOW COLUMNS FROM Student_info\G *************************** 1. row ***************************   Field: studentid    Type: int(11)    Null: YES     Key: Default: NULL   Extra: *************************** 2. row ***************************   Field: Name    Type: varchar(40)    Null: YES     Key: Default: NULL   Extra: *************************** 3. row ***************************   ...

Read More

What happens if I will prepare the statement with the same name without de-allocating the earlier one?

Prabhas
Prabhas
Updated on 20-Jun-2020 163 Views

Actually, in MySQL, we can prepare a statement with the same name without de-allocating the earlier one because MySQL automatically drops the prepared statements when they are redefined or when we close the connection to the server. In other words, we can say that we can use the same name for prepared statements without de-allocating them explicitly. But, to free the memory on the server side we must have to de-allocate them. It can be done with the help of DEALLOCATE statement as follows −DEALLOCATE PREPARE statement;Here statement is the name of the prepared statements.DROP PREPARE statements is the synonym ...

Read More

How can we upload data into MySQL tables by using mysqlimport?

Prabhas
Prabhas
Updated on 20-Jun-2020 402 Views

For uploading the data into MySQL tables by using mysqlimport we need to follow following steps −Step-1 − Creating the tablefirst of all, we need to have a table in which we want to upload the data. We can use CREATE TABLE statement for creating a MySQL table. For example, we created a table named ‘student_tbl’ as follows −mysql> DESCRIBE Student_tbl; +--------+-------------+------+-----+---------+-------+ | Field | Type         | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | RollNo | int(11)     | YES  |     | NULL    |       | | ...

Read More
Showing 31–40 of 52 articles
Advertisements