Smita Kapse

Smita Kapse

388 Articles Published

Articles by Smita Kapse

Page 33 of 39

How can I avoid "repair with keycache" in MySQL?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 377 Views

To avoid repair with keycache in MySQL, you need to follow the below syntax −create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName varchar(20)    ); Query OK, 0 rows affected (0.24 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentFirstName, StudentLastName) values('John', 'Doe'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(StudentFirstName, StudentLastName) values('David', 'Miller'); Query OK, 1 row affected (0.05 sec)Display all records from ...

Read More

How select specific rows in MySQL?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 721 Views

To select specific rows, use FIND_IN_SET() function in MySQL. Let us first create a table −mysql> create table DemoTable    (    ListOfValues varchar(200)    ); Query OK, 0 rows affected (0.31 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('112, 114, 567, Java, 345'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('222, 214, 256'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('2, 567, 98, C'); Query OK, 1 row affected (0.06 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This ...

Read More

MySQL query to display ASC order in number column?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 366 Views

You can achieve this with the help of CAST() function. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Score int    ); Query OK,  0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Score) values(10); Query OK,  1 row affected (0.19 sec) mysql> insert into DemoTable(Score) values(100); Query OK,  1 row affected (0.14 sec) mysql> insert into DemoTable(Score) values(11); Query OK,  1 row affected (0.13 sec) mysql> insert into DemoTable(Score) values(97); Query OK,  1 row affected (0.14 sec) mysql> insert into DemoTable(Score) values(78); Query OK,  1 row affected (0.13 sec) mysql> insert into DemoTable(Score) values(89); Query OK,  1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----+-------+ | Id | Score | +----+-------+ | 1 | 10 | ...

Read More

Listing all rows by group with MySQL GROUP BY?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 1K+ Views

To list all rows by group, you can use GROUP_CONCAT(). Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(20),    Value varchar(100)    ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Value) values('John', 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name, Value) values('Carol', 'Carol'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Name, Value) values('John', 'Works'); Query OK, 1 row affected (0.13 sec) mysql> insert ...

Read More

Java DatabaseMetaData getMaxColumnsInIndex() method with example.

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 99 Views

The getMaxColumnsInIndex() method of the DatabaseMetaData interface is used to find out the maximum number of columns that the underlying database allows in an index.This method returns an integer value, representing the maximum number of columns allowed in an index. If this value is 0 it indicates that there is no limit or, limit is unknown.To get the DatabaseMetaData object −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager ...

Read More

Display all deadlock logs in MySQL?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 4K+ Views

First of all, you need to enable innodb_print_all_deadlocks. Following is the syntax −set global innodb_print_all_deadlocks=1;After executing the above statement, let us execute the below syntax in order to display all deadlock logs −show engine innodb status;Let us implement the above syntax −mysql> set global innodb_print_all_deadlocks=1; Query OK, 0 rows affected (0.00 sec) mysql> show engine innodb status;This will produce the following output −+--------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status ...

Read More

How to align multiple buttons with different height in Java?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 660 Views

To align multiple buttons with different height in Java, try the following example, Here, we have set 5 buttons with GridBagConstraints −GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST;In addition, to set different height for different buttons, we have used −component. getPreferredSize().heightThe following is an example to align multiple buttons with different height −Examplepackage my; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       final JFrame frame = new JFrame(SwingDemo.class.getSimpleName());       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JPanel panel = new JPanel(new GridBagLayout());       GridBagConstraints constraints = new GridBagConstraints();       constraints.insets = new Insets(5,  5,  5,  5);       constraints.anchor = GridBagConstraints.WEST;     ...

Read More

Select last 3 rows from database order by id ASC?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 518 Views

You can use subquery. Following is the syntax −SELECT * FROM (    SELECT * FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 3 ) anyAliasName ORDER BY yourIdColumnName;Let us first create a table −mysql> create table DemoTable (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(100) ); Query OK,  0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientName) values('Larry'); Query OK,  1 row affected (0.18 sec) mysql> insert into DemoTable(ClientName) values('Chris'); Query OK,  1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Bob'); Query OK,  1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('David'); Query OK,  1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Carol'); Query OK,  1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('Robert'); Query OK,  1 row affected (0.19 sec) mysql> insert into DemoTable(ClientName) values('Sam'); Query OK,  1 row affected (0.17 sec) mysql> insert into DemoTable(ClientName) values('Mike'); Query OK,  1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce ...

Read More

How to filter data using where Clause and "LIKE" in Android sqlite?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 850 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to filter data using where Clause and “LIKE” in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill ...

Read More

How to use real data type in Android sqlite?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 442 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use real data type in Android sqliteStep 1 −Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ...

Read More
Showing 321–330 of 388 articles
« Prev 1 31 32 33 34 35 39 Next »
Advertisements