Best Data Type for Storing Currency Values in MySQL Database

George John
Updated on 30-Jul-2019 22:30:23

789 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

C# Equivalent to Java's instanceof

George John
Updated on 30-Jul-2019 22:30:23

827 Views

The java.lang.Class.isInstance() determines if the specified Object is assignment-compatible with the object represented by this Class Java’s isInstance() method’s equivalent in C# is IsAssignableFrom(). Another simplest way for isInstance() equivalent is − bool res = (ob is DemoClass); You can also work with Type.IsInstanceOfType for the same result − ob.GetType().IsInstanceOfType(otherOb)

List Down All Running Queries in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

5K+ Views

To list running queries, we need to use the ‘show processlist’ command. The following is the query. mysql> SHOW processlist; The following is the output of the above query. +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info ... Read More

Remove a MySQL Database

Chandu yadav
Updated on 30-Jul-2019 22:30:23

342 Views

To remove any database, we need to use DROP command in MySQL. Here is the syntax. DROP DATABASE yourDatabaseName; First, let us check how many databases are present in MySQL. Here is the query for the same. mysql> SHOW DATABASES; The following is the output. +--------------------+ | Database | +--------------------+ | business | | database1 | | databasesample | | education ... Read More

Add Not Null Constraint to Existing Column in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

2K+ Views

To add not null constraint to an existing column in MySQL, we will use the ALTER command. This is a type of validation to restrict the user from entering null values. Let us see an example. Firstly, we will create a table. The CREATE command is used to create a table. mysql> create table AddNotNUlldemo - > ( - > name varchar(100) - > ); Query OK, 0 rows affected (0.44 sec) To insert records. mysql> insert into AddNotNUlldemo values('John'); Query OK, 1 row affected (0.19 sec) ... Read More

Use MySQL REPLACE to Replace Strings in Multiple Records

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

1K+ Views

The replace() function can be used to replace a string with another string. To understand replace(), we need to create a table with some records. The following is the query to create a table. mysql> create table replaceDemo -> ( -> Name varchar(200) -> ); Query OK, 0 rows affected (0.55 sec) Insert some records with the help of INSERT command. The query to insert records is as follows − mysql> insert into replaceDemo values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert into replaceDemo values('Demo'); ... Read More

Cable Internet

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

3K+ Views

Cable Internet is a category of broadband Internet access that uses the infrastructure of cable TV network to provide Internet services. Cable Internet provides connectivity from the Internet service provider (ISP) to the end users in a similar manner as digital subscriber line (DSL) and fiber-to-the-home (FTTH). System Layout Broadband cable Internet access has a cable modem termination system (CMTS) at a cable operator facility, called a headend. Headend is connected to switching centers by high bandwidth fiber trunk. Each switching center is connected to one or more fiber nodes through fiber optic cables. The local coaxial cable ... Read More

Add Composite Primary Key in MySQL Using ALTER TABLE

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

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

C# Equivalent to Java's Thread.setDaemon

varun
Updated on 30-Jul-2019 22:30:23

373 Views

C# equivalent to Java's Thread.setDaemon is the concept of foreground and background threads. When the foreground threads will close, the background threads will be terminated. Foreground threads continue to run until the last foreground thread is terminated. The property used for background thread is IsBackground that gets or sets a value indicating whether a thread is a background thread. The default value of this property would be false because the default threads created are Foreground Threads. To make a thread Daemon in C#, use the isBackground − Thread bgThread = new Thread(tStart); bgThread.IsBackground = true; bgThread.Start();

Check for K Consecutive 1's in a Binary Number

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

355 Views

First we take a user input string with the combination of 1’s and 0’s.then create a new string with 1’s, then check if there is any p number of consecutive 1’s is present or not. If present then display FOUND otherwise NOTFOUND. Example Binary number ::1111001111 Enter consecutive 1’s :3 Consecutive 1's is Found Algorithm Step 1: input a string with the combination of 1’s, it’s stored in the variable X and 0’s and p is the consecutive 1’s in a binary number. Step 2: form a new string of p 1’s. newstring=”1”*p Step ... Read More

Advertisements