Multiple Virtual Generated Columns in MySQL Table with CREATE TABLE Statement

Paul Richard
Updated on 22-Jun-2020 14:35:35

316 Views

It is quite possible to add multiple virtual generated columns in a MySQL table. It can be illustrated with the following example as follows −Examplemysql> Create table profit(cost int, price int, profit int AS (price-cost), price_revised int AS (price-2)); Query OK, 0 rows affected (0.73 sec) mysql> Describe profit; +---------------+---------+------+-----+---------+-------------------+ | Field         | Type    | Null | Key | Default | Extra             | +---------------+---------+------+-----+---------+-------------------+ | cost          | int(11) | YES  |     | NULL    |               ... Read More

C# Program to Display the Name of the Directory

Samual Sam
Updated on 22-Jun-2020 14:35:19

172 Views

Firstly, use the DirectoryInfo that operates on Directories. The parameter set in it is the file path −DirectoryInfo dir = new DirectoryInfo(@"D:ew\");To get the name of the directory, use the Name property −dir.NameThe following is the code to display the name of the directory −Example Live Demousing System.IO; using System; public class Program {    public static void Main() {       DirectoryInfo dir = new DirectoryInfo(@"D:ew\");       // displaying the name of the directory       Console.WriteLine(dir.Name);    } }OutputD:ew\

Alter Table to Add MySQL Stored GENERATED COLUMNS

Sharon Christine
Updated on 22-Jun-2020 14:35:06

244 Views

For adding MySQL stored GENERATED COLUMNS in a table, we can use the same syntax as adding a column just adding “AS(expression)” after the data type. Its syntax would be as follows −SyntaxALTER TABLE table_name ADD COLUMN column_name AS(expression)STORED;Examplemysql> ALTER TABLE employee_data_stored ADD COLUMN FULLName Varchar(200) AS (CONCAT_WS(" ", 'First_name', 'Last_name')) STORED; Query OK, 2 rows affected (1.23 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> Describe employee_data_stored; +------------+--------------+------+-----+---------+------------------+ | Field      | Type         | Null | Key | Default | Extra            | +------------+--------------+------+-----+---------+------------------+ | ID       ... Read More

C# Program to Create New Directories

karthikeya Boyini
Updated on 22-Jun-2020 14:34:54

181 Views

Use the CreateDirectory method to create a directory.Let’s say you need to create a directory in D drive. For that, use the CreateDirectory() method as shown below −Directory.CreateDirectory("D:\Tutorial");The following is the code −Exampleusing System.IO; using System; public class Program {    public static void Main() {       Directory.CreateDirectory("D:\Tutorial");    } }

C# Program to Get Information About a File

Samual Sam
Updated on 22-Jun-2020 14:34:31

236 Views

To get information about a file means to get what all attributes are set for that particular file. For example, a file can be normal, hidden, archived, etc.Firstly, use the FileInfo class −FileInfo info = new FileInfo("hello.txt");Now, use FileAttributes to get information about a file −FileAttributes attr = info.Attributes;The following is the code −Example Live Demousing System.IO; using System; public class Program {    public static void Main() {       using (StreamWriter sw = new StreamWriter("hello.txt")) {          sw.WriteLine("This is demo text!");       }       FileInfo info = new FileInfo("hello.txt");       FileAttributes attr = info.Attributes;       Console.WriteLine(attr);    } }OutputNormal

JavaScript Function Definition in Chrome: How to Find It

Giri Raju
Updated on 22-Jun-2020 14:33:58

4K+ Views

To find the JavaScript function definition in Google Chrome, open the web browser and press F12 to reach Developer Tools.Now press Ctrl + Shift + FCheck Regular Expression as shown below −Search for function and that’s it.

C# Program to Get the Name of the Drive

Ankith Reddy
Updated on 22-Jun-2020 14:33:38

210 Views

Set the drive for which you want to display the name −DriveInfo info = new DriveInfo("C");Now, to get the drive name, use the Name property −info.NameHere is the complete code with output −Exampleusing System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       DriveInfo info = new DriveInfo("C");       Console.WriteLine(“Drive: “+info.Name);    } }OutputThe following is the output −D:/

C# Program to Get the Name of Root Directory

George John
Updated on 22-Jun-2020 14:33:02

672 Views

Use the RootDirectory property to get the name of the root directory.Firstly, use DriveInfo to set the drive for which you want the root directory −DriveInfo dInfo = new DriveInfo("C");Now, the RootDirectory gives you the result −dInfo.RootDirectoryExampleHere is the complete code −using System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       DriveInfo dInfo = new DriveInfo("C");       Console.WriteLine("Root Directory: "+dInfo.RootDirectory);    } }OutputThe following is the output −C:\

Get All Drives in C#

Arjun Thakur
Updated on 22-Jun-2020 14:31:43

693 Views

Firstly, use GetDrives to get the name of all the drives −var drv = DriveInfo.GetDrives();Loop through to get the name of all the drives on the system −foreach (DriveInfo dInfo in drv) {    Console.WriteLine(dInfo.Name); }Let us see the complete code −Example Live Demousing System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       var drv = DriveInfo.GetDrives();       foreach (DriveInfo dInfo in drv) {          Console.WriteLine(dInfo.Name);       }    } }Output/etc/resolv.conf /etc/hostname /etc/hosts /run/secrets /home/cg/rootNote: The result will vary on different Operating Systems. The above ... Read More

Get List of MySQL Databases Using PHP Script

Priya Pallavi
Updated on 22-Jun-2020 14:31:14

2K+ Views

We can write the following PHP script to get the list of available MySQL databases −Example

Advertisements