Set Up MySQL User Account Using INSERT INTO Statement

V Jyothi
Updated on 20-Jun-2020 13:19:29

2K+ Views

For adding a new user to MySQL, we just need to add a new entry to the user table in the database mysql. To illustrate it we are using the following example −ExampleThe following program is an example of adding a new user guest with SELECT, INSERT and UPDATE privileges with the password guest123; the SQL query is −root@host# mysql -u root -p Enter password:******* mysql> use mysql; Database changed mysql> INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'guest', PASSWORD('guest123'), 'Y', 'Y’, 'Y'); Query OK, 1 row affected (0.20 sec) mysql> FLUSH PRIVILEGES; Query OK, ... Read More

Difference Between Composition and Aggregation in C#

Ankith Reddy
Updated on 20-Jun-2020 13:19:02

585 Views

Under Composition, if the parent object is deleted, then the child object also loses its status. The composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.public class Engine {    . . . } public class Car {    Engine eng = new Engine();    ....... }Aggregation is a directional relation between objects in C#. It is the relationship between objects.For example, Employee and AddressAn Employee is associated with a single Department, whereas a Department can have more than one employee. Let ... Read More

What is Dynamic Binding in C#

karthikeya Boyini
Updated on 20-Jun-2020 13:18:34

684 Views

In Dynamic binding, the compiler will not do type checking at compile time. At runtime, the checking is done.Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as the return value of a method.Let us see an example −public dynamic GetAnonymousType() {    return new {       StudentName = "Jack",       Subject = "Maths",    }; }Above, the method is set to be dynamic, that would mean the compiler won’t do type checking at compile time −public dynamic GetAnonymousType() {}

What is Early Binding in C#

Arjun Thakur
Updated on 20-Jun-2020 13:18:04

1K+ Views

The mechanism of linking a function with an object during compile time is called early binding. It is also called static binding. C# provides two techniques to implement static polymorphism i.e Function overloading and Operator overloading.Let us learn about Function Overloading with an example −You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.The following is the complete example −Example Live Demousing System; ... Read More

What are Unary Operators in C#

Samual Sam
Updated on 20-Jun-2020 13:17:19

490 Views

The following are the unary operators in C# −+ - ! ~ ++ -- (type)* & sizeofLet us learn about the sizeof operator. The sizeof returns the size of a data type.Let’s say you need to find the size of int datatype −sizeof(int)For double datatype −sizeof(double)Let us see the complete example to find the size of various datatypes −Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          Console.WriteLine("The size of int is {0}", sizeof(int));          Console.WriteLine("The size of int is ... Read More

User Defined Data Types in C#

Chandu yadav
Updated on 20-Jun-2020 13:16:48

3K+ Views

The User defined data types in C# are structures and enumeration.StructureIn C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.The C# structures have the following features −Structures can have methods, fields, indexers, properties, operator methods, and events.Structures can have defined constructors, but not destructors. However, you cannot define a default constructor for a structure. The default constructor is automatically defined and cannot be changed.Unlike classes, structures cannot inherit other structures or classes.Structures cannot be used as ... Read More

Set Up MySQL User Account Using SQL GRANT Statement

radhakrishna
Updated on 20-Jun-2020 13:16:33

189 Views

We can also add user account by using GRANT SQL command. It can be illustrated by using the following example −ExampleIn this example, we will add user Zara with password zara123 for a particular database,which is named as TUTORIALS.root@host# mysql -u root -p password; Enter password:******* mysql> use mysql; Database changed mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP    -> ON TUTORIALS.*    -> TO 'zara'@'localhost'    -> IDENTIFIED BY 'zara123';The above statements will also create an entry in the MySQL database table called as a user.

User Defined Exceptions in C#

karthikeya Boyini
Updated on 20-Jun-2020 13:16:08

827 Views

Like any other programming language, in C#, you can easily create a user-defined exception. User-defined exception classes are derived from the Exception class. Custom exceptions are what we call user-defined exceptions.In the below example, the exception created is not a built-in exception; it is a custom exception −TempIsZeroExceptionYou can try to run the following code to learn how to create a user-defined exception in C# −Example Live Demousing System; namespace Demo {    class TestTemperature {       static void Main(string[] args) {          Temperature temp = new Temperature();          try {   ... Read More

What is Aggregation in C#

Arjun Thakur
Updated on 20-Jun-2020 13:15:21

462 Views

Aggregation is a directional relation between objects in C#. It is the relationship between objects.For example, Employee and AddressAn Employee is associated with a single Department, whereas a Department can have more than one employee. Let us see an example of Employee and Address −public class Address {    . . . } public class Employee {    private Address addr;    public Employee (Address addr) {       this.addr = addr;    }    . . . }

Get Randomly Different Rows from MySQL Table

Arushi
Updated on 20-Jun-2020 13:14:05

145 Views

When we use RAND() function along with both ORDER BY and LIMIT clause in a query, MySQL returns the different set of rows or values each time. To understand it considers a table ‘Employee’ having the following records −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary | +----+--------+--------+ | 1  | Gaurav | 50000  | | 2  | Rahul  | 20000  | | 3  | Advik  | 25000  | | 4  | Aarav  | 65000  | | 5  | Ram    | 20000  | | 6  | Mohan  | 30000  | | 7  | Aryan ... Read More

Advertisements