在sql中用count语句进行记录数统计,count(*)表示统计所有记录数。
正确答案是:B: `select count(*) from student`
分析:
- A: `select count() from student`
这个语句是错误的,因为 `count()` 函数需要一个参数,比如列名或星号 `*`,来指明要统计的内容。
- B: `select count(*) from student`
这个语句是正确的。`count(*)` 会统计表中所有行的数量,包括所有列。这是一个常用的查询记录总数的方式。
- C: `select columns() from student`
这个语句是错误的,因为 SQL 中没有 `columns()` 这样的函数。通常,用 `information_schema` 或 `sys` 表来查询列信息。
- D: `select columns(*) from student`
这个语句也是错误的,同样因为不存在 `columns()` 这样的函数。
因此,B 是正确的选项,`select count(*) from student` 是查询 `student` 表中记录数的正确语句。