How can we apply UNIQUE constraint to the field of an existing MySQL table?

Swarali Sree
Updated on 19-Jun-2020 11:47:43

589 Views

We can apply the UNIQUE constraint to a column of an existing MySQL table with the help of ALTER TABLE statement.SyntaxALTER TABLE table_name MODIFY colum_name datatype UNIQUE;                     OR ALTER TABLE table_name ADD UNIQUE (colum_name);ExampleSuppose we have the following table named ‘Test4’ and we want to add UNIQUE constraint to the column ‘Name’ then it can be done with the help of ALTER TABLE command as follows −mysql> DESCRIBE test4; +-------+-------------+------+-----+---------+-------+ | Field | Type        | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | ID   ... Read More

C# Program to pass Parameter to a Thread

Samual Sam
Updated on 19-Jun-2020 11:47:31

5K+ Views

To work with threads, add the following namespace in your code −using System.Threading;Firstly, you need to create a new thread in C# −Thread thread = new Thread(threadDemo);Above, threadDemo is our thread function.Now pass a parameter to the thread −thread.Start(str);The parameter set above is −String str = "Hello World!";ExampleLet us see the complete code to pass a parameter to a thread in C#.Live Demousing System; using System.Threading; namespace Sample {    class Demo {       static void Main(string[] args) {          String str = "Hello World!";          // new thread       ... Read More

C# Program to perform all Basic Arithmetic Operations

Samual Sam
Updated on 19-Jun-2020 11:44:15

10K+ Views

Basic Arithmetic Operators in C#, include the following −OperatorDescription+Adds two operands-Subtracts the second operand from the first*Multiplies both operands/Divides the numerator by de-numerator%Modulus Operator and remainder of after an integer division++Increment operator increases integer value by one--Decrement operator decreases integer value by oneTo add, use the Addition Operator −num1 + num2;In the same way, it works for Subtraction, Multiplication, Division, and other operators.ExampleLet us see a complete example to learn how to implement Arithmetic operators in C#.Live Demousing System; namespace Sample {    class Demo {       static void Main(string[] args) {          int num1 ... Read More

C# program to find the maximum of three numbers

karthikeya Boyini
Updated on 19-Jun-2020 11:38:44

14K+ Views

Firstly, let’s set the three numbers −int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.ExampleYou can try to run the following code to find the maximum of three numbers.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {          int ... Read More

C# Program to create a Simple Thread

Samual Sam
Updated on 19-Jun-2020 11:38:02

616 Views

To create a thread, I have created a function −public void myThread() {    for (int i = 0; i < 3; i++) {       Console.WriteLine("My Thread");    } }The above function is called to create a thread and a new ThreadStart delegate is created −Demo d = new Demo(); Thread thread = new Thread(new ThreadStart(d.myThread));ExampleCreate a simple thread using the following code.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; class Demo {    public void myThread() {       for (int i = 0; i < 3; i++) {         ... Read More

C# Program to Create a Thread Pool

karthikeya Boyini
Updated on 19-Jun-2020 11:36:47

710 Views

For a thread pool, create more than two functions and queue methods for execution.Firstly, create a method like −public void one(object o) {    for (int i = 0; i

C# program to Display Hostname and IP address

karthikeya Boyini
Updated on 19-Jun-2020 11:35:28

1K+ Views

To find the hostname, use the Dns.GetHostName() method in C# −String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName);Now, use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;ExampleTry the following code to display hostname and IP address −using System; using System.Net; class Program {    static void Main() {       String hostName = string.Empty;       hostName = Dns.GetHostName();       Console.WriteLine("Hostname: "+hostName);       IPHostEntry myIP = Dns.GetHostEntry(hostName);       IPAddress[] address = myIP.AddressList;       for (int i = 0; i < address.Length; i++) {          Console.WriteLine("IP Address {1} : ",address[i].ToString());       }       Console.ReadLine();    } }

Spatial Databases

David Meador
Updated on 19-Jun-2020 11:35:00

24K+ Views

Spatial data is associated with geographic locations such as cities, towns etc. A spatial database is optimized to store and query data representing objects. These are the objects which are defined in a geometric space.Characteristics of Spatial DatabaseA spatial database system has the following characteristicsIt is a database systemIt offers spatial data types (SDTs) in its data model and query language.It supports spatial data types in its implementation, providing at least spatial indexing and efficient algorithms for spatial join.ExampleA road map is a visualization of geographic information. A road map is a 2-dimensional object which contains points, lines, and polygons ... Read More

C# program to replace all spaces in a string with ‘%20’

karthikeya Boyini
Updated on 19-Jun-2020 11:33:45

3K+ Views

We have a sample string with spaces −str ="Hello World !";Use the Replace() method in C# to replace all spaces in a string with ‘%20’ −str2 = str.Replace(" ", "%20");ExampleYou can try to run the following code to replace all spaces in a string with ‘%20’.Live Demousing System; class Demo {    static void Main() {       String str, str2;       str ="Hello World !";       Console.WriteLine("String: "+str);       str2 = str.Replace(" ", "%20");       Console.WriteLine("String (After replacing): "+str2);    } }OutputString: Hello World ! String (After replacing): Hello%20World%20!

How to return a value from a JavaScript function?

Srinivas Gorla
Updated on 19-Jun-2020 11:31:35

3K+ Views

To return a value from a JavaScript function, use the return statement in JavaScript. You need to run the following code to learn how to return a value −Example                    function concatenate(name, age) {             var val;             val = name + age;             return val;          }          function DisplayFunction() {             var result;             result = concatenate('John ', 20) ;             document.write (result );          }                     Click the following button to call the function                          

Advertisements