Add FOREIGN KEY Constraint to Existing MySQL Table

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

2K+ Views

We can add a FOREIGN KEY constraint to a column of an existing MySQL table with the help of ALTER TABLE statement. Syntax ALTER TABLE table_name ADD FOREIGN KEY (colum_name) REFERENCES table having Primary Key(column_name); Example Suppose we want to add a FOREIGN KEY constraint on the table ‘Orders1’ referencing to the table ‘Customer’ which have column ‘Cust_Id’ as the Primary Key. It can be done with the help of the following query − mysql> Alter table orders1 add FOREIGN KEY(Cust_id) REFERENCES Customer(Cust_id); Query OK, 0 rows affected (0.21 sec) Records: 0  Duplicates: 0  Warnings: 0   mysql> ... Read More

Use Week Input Type in HTML

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

463 Views

The week input type is used in HTML using the . Using this, allow users to select a week and year. A date picker popup is visible whenever you will give a user input to the week input type. Note − The input type week is not supported in Firefox and Internet Explorer. It works on Google Chrome. You can try to run the following code to learn how to use week input type in HTML. It will show both week and year. Example Live Demo HTML input week Details: Student Name Training week

Append Method in Java

Moumita
Updated on 30-Jul-2019 22:30:21

3K+ Views

The append(char c) method of the java.lang.StringBuffer appends the string representation of the char argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by 1.Example Live Demoimport java.lang.*; public class StringBufferDemo {    public static void main(String[] args) {       StringBuffer buff = new StringBuffer("tuts ");       System.out.println("buffer = " + buff);             // appends the char argument as string to the string buffer.       buff.append('A');             // print the string buffer after appending ... Read More

MySQL Temporary Tables and Session End Behavior

seetha
Updated on 30-Jul-2019 22:30:21

159 Views

Temporary table would be deleted if MySQL session terminates. After login again, on issuing the SELECT command we will find no data available in the database. Even our temporary table will not exist.

What is MySQL INTERVAL Function

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

508 Views

MySQL INTERVAL() function returns the index value of the argument which is greater than the first argument. Syntax INTERVAL(N,N1,N2,N3,…) Here, this function will compare 1st argument i.e. N with the other arguments i.e. N1, N2, N3 and so on. All the arguments are treated as integers. It returns the output as follows − If N

The Auto Storage Class in C++

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:21

247 Views

In C, The auto storage class specifier lets you explicitly declare a variable with automatic storage. The auto storage class is the default for variables declared inside a block. A variable x that has automatic storage is deleted when the block in which x was declared exits.You can only apply the auto storage class specifier to names of variables declared in a block or to names of function parameters. However, these names by default have automatic storage. Therefore the storage class specifier auto is usually redundant in a data declaration.It was initially carried over to C++ for syntactical compatibility only, ... Read More

Compare Strings in Java

Giri Raju
Updated on 30-Jul-2019 22:30:21

262 Views

https://www.tutorialspoint.com/javaexamples/string_compare.htm

String in Switch Case in Java

Govinda Sai
Updated on 30-Jul-2019 22:30:21

235 Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Example Live Demopublic class Test {    public static void main(String args[]) {       // char grade = args[0].charAt(0);       char grade = 'C';       switch(grade) {          case 'A' :             System.out.println("Excellent!");             break;          case 'B' :          case 'C' :   ... Read More

The Register Storage Class in C++

Nitya Raut
Updated on 30-Jul-2019 22:30:21

365 Views

In C, the register storage class specifier indicates to the compiler that the object should be stored in a machine register. The register storage class specifier is typically specified for heavily used variables, such as a loop control variable, in the hopes of enhancing performance by minimizing access time. However, the compiler is not required to honor this request. Because of the limited size and number of registers available on most systems, few variables can actually be put in registers.In C++ it is simply an unused reserved keyword, but it's reasonable to assume that it was kept for syntactical compatibility ... Read More

RAND Function Behavior in SQL Queries

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

301 Views

We know that MySQL RAND() returns a random floating point value between the range of 0 and 1. It will generate two different random numbers if we will call the RAND() function, without seed, two times in the same query. Following example will make it clearer − Example mysql> Select RAND(), RAND(), Rand(); +--------------------+-------------------+--------------------+ | RAND() | RAND() | Rand() | +--------------------+-------------------+--------------------+ | 0.9402844448949066 | 0.911499003797303 | 0.7366417150354402 | +--------------------+-------------------+--------------------+ 1 row in set (0.00 sec) The above result set shows that RAND() function will generate different random number every time we call it.

Advertisements